From 84578a64c6fa5bdaae03f040b4b7a17fdc2c22ab Mon Sep 17 00:00:00 2001 From: Jagandeep Brar Date: Sun, 3 Apr 2022 14:40:25 -0400 Subject: [PATCH] chore(ci): abstract out build and deployment actions --- .github/actions/prepare_for_build/action.yml | 135 +++++++++++++++++ .../actions/prepare_for_deployment/action.yml | 77 ++++++++++ .github/workflows/build_android.yml | 90 +++-------- .github/workflows/build_ios.yml | 46 +----- .github/workflows/build_linux.yml | 23 +-- .github/workflows/build_macos.yml | 98 +++--------- .github/workflows/build_web.yml | 28 +--- .github/workflows/prepare.yml | 57 +++---- .github/workflows/publish.yml | 141 +++++++----------- .github/workflows/release.yml | 26 ++-- .github/workflows/validate.yml | 22 +-- 11 files changed, 365 insertions(+), 378 deletions(-) create mode 100644 .github/actions/prepare_for_build/action.yml create mode 100644 .github/actions/prepare_for_deployment/action.yml diff --git a/.github/actions/prepare_for_build/action.yml b/.github/actions/prepare_for_build/action.yml new file mode 100644 index 0000000000..4b59f9180c --- /dev/null +++ b/.github/actions/prepare_for_build/action.yml @@ -0,0 +1,135 @@ +name: 'Prepare for Build' +description: 'Setup all required dependencies and secrets for building the given platform' + +inputs: + platform: + description: 'Platform to be Built' + required: true + + # Secret Keys + android-key-jks: + description: 'Android Signing Key' + required: false + default: '' + android-key-properties: + description: 'Android Signing Key Properties' + required: false + default: '' + appstore-connect-key: + description: 'App Store Connect API Key' + required: false + default: '' + firebase-options: + description: 'Firebase Configuration' + required: false + default: '' + google-play-key: + description: 'Google Play Store API Key' + required: false + default: '' + match-ssh-private-key: + description: 'Fastlane Match SSH Key' + required: false + default: '' + +runs: + using: composite + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Prepare Core + uses: actions/download-artifact@v3 + with: + name: core-files + + - name: Prepare Folders + shell: bash + run: | + mkdir -p output + mkdir -p keys + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - name: Install Java + if: ${{ inputs.platform == 'android' }} + uses: actions/setup-java@v2 + with: + distribution: zulu + java-version: 11 + + - name: Install Ruby + if: ${{ inputs.platform == 'android' || inputs.platform == 'ios' || inputs.platform == 'macos' }} + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Install XCode + if: ${{ inputs.platform == 'ios' || inputs.platform == 'macos' }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Setup Match SSH Keys + if: ${{ inputs.platform == 'ios' || inputs.platform == 'macos' }} + uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ inputs.match-ssh-private-key }} + + - name: Setup Secret Keys + shell: bash + run: | + echo ${{ inputs.appstore-connect-key }} | base64 --decode > keys/appstore.p8 + echo ${{ inputs.google-play-key }} | base64 --decode > keys/googleplay.json + echo ${{ inputs.android-key-jks }} | base64 --decode > android/key.jks + echo ${{ inputs.android-key-properties }} | base64 --decode > android/key.properties + echo ${{ inputs.firebase-options }} | base64 --decode > lib/firebase_options.dart + + - name: Setup Android Platform + if: ${{ inputs.platform == 'android' }} + shell: bash + run: | + flutter pub get + (cd android && bundle install) + + - name: Setup iOS Platform + if: ${{ inputs.platform == 'ios' }} + shell: bash + run: | + flutter pub get + (cd ios && pod install --repo-update) + (cd ios && bundle install) + + - name: Setup Linux Platform + if: ${{ inputs.platform == 'linux' }} + shell: bash + run: | + flutter config --enable-linux-desktop + flutter pub get + + - name: Setup macOS Platform + if: ${{ inputs.platform == 'macos' }} + shell: bash + run: | + flutter config --enable-macos-desktop + flutter pub get + (cd macos && pod install --repo-update) + (cd macos && bundle install) + + - name: Setup Web Platform + if: ${{ inputs.platform == 'web' }} + shell: bash + run: | + flutter pub get + + - name: Setup Test Platform + if: ${{ inputs.platform == 'test' }} + shell: bash + run: | + flutter pub get \ No newline at end of file diff --git a/.github/actions/prepare_for_deployment/action.yml b/.github/actions/prepare_for_deployment/action.yml new file mode 100644 index 0000000000..93e31ab23e --- /dev/null +++ b/.github/actions/prepare_for_deployment/action.yml @@ -0,0 +1,77 @@ +name: 'Prepare for Deployment' +description: 'Setup all required dependencies and secrets for the given release channel' + +inputs: + channel: + description: 'Release Channel' + required: true + + # Secret Keys + appstore-connect-key: + description: 'App Store Connect API Key' + required: false + default: '' + google-play-key: + description: 'Google Play Store API Key' + required: false + default: '' + snapcraft-token: + description: 'Snapcraft API Key' + required: false + default: '' + +runs: + using: composite + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Prepare Folders + shell: bash + run: | + mkdir -p output + mkdir -p keys + + - name: Install Ruby + if: ${{ inputs.channel == 'play-store' || inputs.channel == 'app-store' }} + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Install Snapcraft + if: ${{ inputs.channel == 'snapcraft' }} + uses: samuelmeuli/action-snapcraft@v1 + with: + snapcraft_token: ${{ inputs.snapcraft-token }} + + - name: Install XCode + if: ${{ inputs.channel == 'app-store' }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Setup Secret Keys + shell: bash + run: | + echo ${{ inputs.appstore-connect-key }} | base64 --decode > keys/appstore.p8 + echo ${{ inputs.google-play-key }} | base64 --decode > keys/googleplay.json + + - name: Setup Android Platform + if: ${{ inputs.channel == 'play-store' }} + shell: bash + run: | + cd android && bundle install + + - name: Setup iOS Platform + if: ${{ inputs.channel == 'app-store' }} + shell: bash + run: | + cd ios && bundle install + + - name: Setup macOS Platform + if: ${{ inputs.channel == 'app-store' }} + shell: bash + run: | + cd macos && bundle install diff --git a/.github/workflows/build_android.yml b/.github/workflows/build_android.yml index 1cf5c73586..d40b0bf458 100644 --- a/.github/workflows/build_android.yml +++ b/.github/workflows/build_android.yml @@ -3,7 +3,7 @@ name: 'Build Android' on: workflow_call: inputs: - build_number: + build-number: required: true type: string @@ -16,49 +16,21 @@ on: required: true jobs: - build_playstore_package: + build-playstore-package: name: Play Store Package runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - fetch-depth: 0 - - - name: Install Core Files - uses: actions/download-artifact@v3 - with: - name: core_files - - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Install Java - uses: actions/setup-java@v2 - with: - distribution: zulu - java-version: 11 - - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true - cache-key: ${{ github.sha }} + platform: android + android-key-jks: ${{ secrets.KEY_JKS }} + android-key-properties: ${{ secrets.KEY_PROPERTIES }} + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} - name: Build LunaSea working-directory: ${{ github.workspace }}/android - env: - SUPPLY_JSON_KEY: ${{ github.workspace }}/.fastlane-android-auth.json - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > ../lib/firebase_options.dart - echo ${{ secrets.KEY_JKS }} | base64 --decode > ../android/key.jks - echo ${{ secrets.KEY_PROPERTIES }} | base64 --decode > ../android/key.properties - flutter pub get - bundle install - bundle exec fastlane build_aab build_number:${{ inputs.build_number }} + run: bundle exec fastlane build_aab build-number:${{ inputs.build-number }} - name: Upload Artifact uses: actions/upload-artifact@v3 @@ -66,49 +38,21 @@ jobs: name: android-playstore-package path: ${{ github.workspace }}/output - build_app_package: + build-app-package: name: App Package runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Install Core Files - uses: actions/download-artifact@v3 - with: - name: core_files - - - name: Install Ruby - uses: ruby/setup-ruby@v1 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - bundler-cache: true + platform: android + android-key-jks: ${{ secrets.KEY_JKS }} + android-key-properties: ${{ secrets.KEY_PROPERTIES }} + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} - - name: Install Java - uses: actions/setup-java@v2 - with: - distribution: zulu - java-version: 11 - - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true - cache-key: ${{ github.sha }} - - name: Build LunaSea working-directory: ${{ github.workspace }}/android - env: - SUPPLY_JSON_KEY: ${{ github.workspace }}/.fastlane-android-auth.json - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > ../lib/firebase_options.dart - echo ${{ secrets.KEY_JKS }} | base64 --decode > ../android/key.jks - echo ${{ secrets.KEY_PROPERTIES }} | base64 --decode > ../android/key.properties - flutter pub get - bundle install - bundle exec fastlane build_apk build_number:${{ inputs.build_number }} + run: bundle exec fastlane build_apk build_number:${{ inputs.build-number }} - name: Upload Artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/build_ios.yml b/.github/workflows/build_ios.yml index 43da52c8d7..c931112b53 100644 --- a/.github/workflows/build_ios.yml +++ b/.github/workflows/build_ios.yml @@ -3,7 +3,7 @@ name: 'Build iOS' on: workflow_call: inputs: - build_number: + build-number: required: true type: string @@ -26,41 +26,16 @@ on: required: true jobs: - build_appstore_package: + build-appstore-package: name: App Store Package runs-on: macos-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - fetch-depth: 0 - - - name: Install Core Files - uses: actions/download-artifact@v3 - with: - name: core_files - - - name: Select Xcode Version - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Setup SSH Agent - uses: webfactory/ssh-agent@v0.5.4 - with: - ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true - cache-key: ${{ github.sha }} + platform: ios + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} + match-ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - name: Build LunaSea working-directory: ${{ github.workspace }}/ios @@ -71,12 +46,7 @@ jobs: MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > ../lib/firebase_options.dart - flutter pub get - pod install --repo-update - bundle install - bundle exec fastlane build_appstore build_number:${{ inputs.build_number }} + run: bundle exec fastlane build_appstore build_number:${{ inputs.build-number }} - name: Upload Artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 02ce5047b1..427bd7fc5a 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -3,7 +3,7 @@ name: 'Build Linux' on: workflow_call: inputs: - build_number: + build-number: required: true type: string @@ -12,31 +12,22 @@ on: required: true jobs: - build_snap: + build-snap: name: Snap runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - fetch-depth: 0 - - - name: Install Core Files - uses: actions/download-artifact@v3 - with: - name: core_files - - - name: Prepare Build - run: echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > lib/firebase_options.dart + platform: linux + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} - name: Build LunaSea uses: snapcore/action-build@v1 id: build - name: Prepare Artifact - run: | - mkdir -p output - mv ${{ steps.build.outputs.snap }} ${{ github.workspace }}/output/LunaSea-Linux-amd64.snap + run: mv ${{ steps.build.outputs.snap }} ${{ github.workspace }}/output/LunaSea-Linux-amd64.snap - name: Upload Artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 1b8e7d2b03..54528b99c7 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -3,7 +3,7 @@ name: 'Build macOS' on: workflow_call: inputs: - build_number: + build-number: required: true type: string @@ -16,8 +16,6 @@ on: required: true APPLE_STORE_CONNECT_KEY: required: true - APPLE_STORE_CONNECT_KEY_FILEPATH: - required: true APPLE_STORE_CONNECT_KEY_ID: required: true APPLE_TEAM_ID: @@ -34,41 +32,16 @@ on: required: true jobs: - build_appstore_package: + build-appstore-package: name: App Store Package runs-on: macos-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Install Core Files - uses: actions/download-artifact@v3 - with: - name: core_files - - - name: Select Xcode Version - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Setup SSH Agent - uses: webfactory/ssh-agent@v0.5.4 - with: - ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Install Flutter - uses: subosito/flutter-action@v2 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - channel: stable - cache: true - cache-key: ${{ github.sha }} + platform: macos + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} + match-ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - name: Build LunaSea working-directory: ${{ github.workspace }}/macos @@ -79,13 +52,7 @@ jobs: MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > ../lib/firebase_options.dart - flutter config --enable-macos-desktop - flutter pub get - pod install --repo-update - bundle install - bundle exec fastlane build_appstore build_number:${{ inputs.build_number }} + run: bundle exec fastlane build_appstore build_number:${{ inputs.build-number }} - name: Upload Artifact uses: actions/upload-artifact@v3 @@ -93,41 +60,17 @@ jobs: name: macos-appstore-package path: ${{ github.workspace }}/output - build_noatized_package: + build-noatized-package: name: Notarized Package runs-on: macos-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Install Core Files - uses: actions/download-artifact@v3 - with: - name: core_files - - - name: Select Xcode Version - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Setup SSH Agent - uses: webfactory/ssh-agent@v0.5.4 - with: - ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Install Flutter - uses: subosito/flutter-action@v2 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - channel: stable - cache: true - cache-key: ${{ github.sha }} + platform: macos + appstore-connect-key: ${{ secrets.APPLE_STORE_CONNECT_KEY }} + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} + match-ssh-private-key: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - name: Build LunaSea working-directory: ${{ github.workspace }}/macos @@ -135,20 +78,13 @@ jobs: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} APPLE_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} - APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} + APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ github.workspace }}/keys/appstore.p8 APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > ../lib/firebase_options.dart - echo ${{ secrets.APPLE_STORE_CONNECT_KEY }} | base64 --decode > ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} - flutter config --enable-macos-desktop - flutter pub get - pod install --repo-update - bundle install - bundle exec fastlane build_direct build_number:${{ inputs.build_number }} + run: bundle exec fastlane build_direct build_number:${{ inputs.build-number }} - name: Upload Artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/build_web.yml b/.github/workflows/build_web.yml index a6bc65974f..b25b85eead 100644 --- a/.github/workflows/build_web.yml +++ b/.github/workflows/build_web.yml @@ -3,7 +3,7 @@ name: 'Build Web' on: workflow_call: inputs: - build_number: + build-number: required: true type: string @@ -12,32 +12,18 @@ on: required: true jobs: - build: + build-canvaskit: name: CanvasKit runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - fetch-depth: 0 - - - name: Install Core Files - uses: actions/download-artifact@v3 - with: - name: core_files - - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true - cache-key: ${{ github.sha }} + platform: web + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} - name: Build LunaSea - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > lib/firebase_options.dart - flutter pub get - flutter build web --web-renderer canvaskit --release + run: flutter build web --web-renderer canvaskit --release - name: Upload Artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/prepare.yml b/.github/workflows/prepare.yml index 3f978d60cd..393d13ddff 100644 --- a/.github/workflows/prepare.yml +++ b/.github/workflows/prepare.yml @@ -8,26 +8,26 @@ on: required: true outputs: - build_number: + build-number: description: "Build Number" - value: ${{ jobs.build_number.outputs.build_number }} - build_title: + value: ${{ jobs.build-number.outputs.build-number }} + build-title: description: "Build Title" - value: ${{ jobs.build_title.outputs.build_title }} - build_version: + value: ${{ jobs.build-title.outputs.build-title }} + build-version: description: "Build Version" - value: ${{ jobs.build_version.outputs.build_version }} + value: ${{ jobs.build-version.outputs.build-version }} secrets: FIREBASE_OPTIONS: required: true jobs: - build_number: + build-number: name: Build Number runs-on: ubuntu-latest outputs: - build_number: ${{ steps.output.outputs.build_number }} + build-number: ${{ steps.output.outputs.build-number }} steps: - name: Checkout Repository uses: actions/checkout@v2 @@ -56,18 +56,16 @@ jobs: id: output run: | echo ${{ steps.script.outputs.result }} - echo "::set-output name=build_number::${{ steps.script.outputs.result }}" + echo "::set-output name=build-number::${{ steps.script.outputs.result }}" - build_version: + build-version: name: Build Version runs-on: ubuntu-latest outputs: - build_version: ${{ steps.output.outputs.build_version }} + build-version: ${{ steps.output.outputs.build-version }} steps: - name: Checkout Repository uses: actions/checkout@v2 - with: - fetch-depth: 0 - name: Get Version id: version @@ -77,14 +75,14 @@ jobs: id: output run: | echo ${{ steps.version.outputs.current-version }} - echo "::set-output name=build_version::${{ steps.version.outputs.current-version }}" + echo "::set-output name=build-version::${{ steps.version.outputs.current-version }}" - build_title: + build-title: name: Build Title - needs: [ build_number, build_version ] + needs: [ build-number, build-version ] runs-on: ubuntu-latest outputs: - build_title: ${{ steps.output.outputs.build_title }} + build-title: ${{ steps.output.outputs.build-title }} steps: - name: Checkout Repository uses: actions/checkout@v2 @@ -98,28 +96,19 @@ jobs: - name: Set Output id: output run: | - TITLE="v${{ needs.build_version.outputs.build_version }}-${{ inputs.flavor }}-${{ needs.build_number.outputs.build_number }}-${{ steps.hash.outputs.hash }}" + TITLE="v${{ needs.build-version.outputs.build-version }}-${{ inputs.flavor }}-${{ needs.build-number.outputs.build-number }}-${{ steps.hash.outputs.hash }}" echo $TITLE - echo "::set-output name=build_title::$TITLE" + echo "::set-output name=build-title::$TITLE" - generate_files: + generate-files: name: Generate Files runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Flutter - uses: subosito/flutter-action@v2 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - channel: stable - cache: true - cache-key: ${{ github.sha }} - - - name: Prepare Generation - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > lib/firebase_options.dart - flutter pub get + platform: test + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} - name: Generate Flavor Configuration run: echo $'FLAVOR=${{ inputs.flavor }}\nCOMMIT=${{ github.sha }}' > .flavor @@ -133,7 +122,7 @@ jobs: - name: Upload Core Files uses: actions/upload-artifact@v3 with: - name: core_files + name: core-files path: | ${{ github.workspace }}/.flavor ${{ github.workspace }}/assets/localization diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5967db71d8..b418150c01 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,7 +6,7 @@ on: flavor: required: true type: string - build_title: + build-title: required: true type: string @@ -19,8 +19,6 @@ on: required: true APPLE_STORE_CONNECT_KEY: required: true - APPLE_STORE_CONNECT_KEY_FILEPATH: - required: true APPLE_STORE_CONNECT_KEY_ID: required: true APPLE_TEAM_ID: @@ -51,20 +49,15 @@ on: required: true jobs: - android_play_store: + android-play-store: name: Play Store runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Ruby - uses: ruby/setup-ruby@v1 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master with: - bundler-cache: true - - - name: Prepare Download - run: mkdir -p ${{ github.workspace }}/output + channel: play-store + google-play-key: ${{ secrets.GOOGLE_PLAY_API }} - name: Download Play Store Package uses: actions/download-artifact@v3 @@ -80,38 +73,30 @@ jobs: with: result-encoding: string script: | - const ref = process.env.FLAVOR || "edge"; + const ref = process.env.FLAVOR || 'edge'; switch (ref) { - case "beta": return "alpha"; - case "candidate": return "beta"; - case "stable": return "production"; - case "edge": - default: return "internal"; + case 'beta': return 'alpha'; + case 'candidate': return 'beta'; + case 'stable': return 'production'; + case 'edge': + default: return 'internal'; } - name: Deploy to Google Play Store working-directory: ${{ github.workspace }}/android env: - SUPPLY_JSON_KEY: ${{ github.workspace }}/android/.fastlane-android-auth.json - run: | - echo ${{ secrets.GOOGLE_PLAY_API }} | base64 --decode > .fastlane-android-auth.json - bundle install - bundle exec fastlane deploy_playstore track:${{ steps.channel.outputs.result }} aab:${{ github.workspace }}/output/LunaSea-Android.aab version_name:${{ inputs.build_title }} + SUPPLY_JSON_KEY: ${{ github.workspace }}/keys/googleplay.json + run: bundle exec fastlane deploy_playstore track:${{ steps.channel.outputs.result }} aab:${{ github.workspace }}/output/LunaSea-Android.aab version_name:${{ inputs.build-title }} - ios_app_store: + ios-app-store: name: App Store (iOS) runs-on: macos-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Ruby - uses: ruby/setup-ruby@v1 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master with: - bundler-cache: true - - - name: Prepare Download - run: mkdir -p ${{ github.workspace }}/output + channel: app-store + appstore-connect-key: ${{ secrets.APPLE_STORE_CONNECT_KEY }} - name: Download App Store Package uses: actions/download-artifact@v3 @@ -125,20 +110,20 @@ jobs: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} APPLE_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} - APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} + APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ github.workspace }}/keys/appstore.p8 APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - run: | - echo ${{ secrets.APPLE_STORE_CONNECT_KEY }} | base64 --decode > ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} - bundle install - bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} ipa:${{ github.workspace }}/output/LunaSea-iOS.ipa + run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} ipa:${{ github.workspace }}/output/LunaSea-iOS.ipa - linux_snapcraft: + linux-snapcraft: name: Snapcraft runs-on: ubuntu-latest steps: - - name: Prepare Download - run: mkdir -p ${{ github.workspace }}/output + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master + with: + channel: snapcraft + snapcraft-token: ${{ secrets.SNAPCRAFT_TOKEN }} - name: Download Snap uses: actions/download-artifact@v3 @@ -146,28 +131,18 @@ jobs: name: linux-snap path: ${{ github.workspace }}/output - - name: Install Snapcraft - uses: samuelmeuli/action-snapcraft@v1 - with: - snapcraft_token: ${{ secrets.SNAPCRAFT_TOKEN }} - - name: Deploy to Snapcraft run: snapcraft upload --release=${{ inputs.flavor }} ${{ github.workspace }}/output/LunaSea-Linux-amd64.snap - macos_app_store: + macos-app-store: name: App Store (macOS) runs-on: macos-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Prepare Download - run: mkdir -p ${{ github.workspace }}/output - - - name: Install Ruby - uses: ruby/setup-ruby@v1 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master with: - bundler-cache: true + channel: app-store + appstore-connect-key: ${{ secrets.APPLE_STORE_CONNECT_KEY }} - name: Download App Store Package uses: actions/download-artifact@v3 @@ -181,20 +156,19 @@ jobs: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} APPLE_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} - APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} + APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ github.workspace }}/keys/appstore.p8 APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - run: | - echo ${{ secrets.APPLE_STORE_CONNECT_KEY }} | base64 --decode > ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} - bundle install - bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} pkg:${{ github.workspace }}/output/LunaSea-macOS.pkg + run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} pkg:${{ github.workspace }}/output/LunaSea-macOS.pkg - web_netlify: + web-netlify: name: Netlify runs-on: ubuntu-latest steps: - - name: Prepare Download - run: mkdir -p ${{ github.workspace }}/output + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master + with: + channel: netlify - name: Download Web Package uses: actions/download-artifact@v3 @@ -210,13 +184,13 @@ jobs: with: result-encoding: string script: | - const ref = process.env.FLAVOR || "edge"; + const ref = process.env.FLAVOR || 'edge'; switch (ref) { - case "beta": return "11ef2676-fc31-41b5-897b-fd21273d87ed"; - case "candidate": return "4636e6a1-17ef-45a2-a2b6-3d1c166fd1df"; - case "stable": return "6634f0b1-323c-4a2f-bd0b-8f1f388673a9"; - case "edge": - default: return "325e197e-55f4-449a-b2bb-6831fe47bf2a"; + case 'beta': return '11ef2676-fc31-41b5-897b-fd21273d87ed'; + case 'candidate': return '4636e6a1-17ef-45a2-a2b6-3d1c166fd1df'; + case 'stable': return '6634f0b1-323c-4a2f-bd0b-8f1f388673a9'; + case 'edge': + default: return '325e197e-55f4-449a-b2bb-6831fe47bf2a'; } - name: Deploy to Netlify @@ -227,14 +201,16 @@ jobs: with: publish-dir: ${{ github.workspace}}/output production-deploy: true - deploy-message: ${{ inputs.build_title }} + deploy-message: ${{ inputs.build-title }} s3: name: S3 runs-on: ubuntu-latest steps: - - name: Prepare Download - run: mkdir -p ${{ github.workspace }}/output + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master + with: + channel: s3 - name: Download Android App Package uses: actions/download-artifact@v3 @@ -271,7 +247,7 @@ jobs: AWS_S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} AWS_REGION: ${{ secrets.S3_REGION }} SOURCE_DIR: ${{ github.workspace }}/output - DEST_DIR: ${{ inputs.build_title }} + DEST_DIR: ${{ inputs.build-title }} - name: Determine Webhook Channel id: webhook @@ -282,16 +258,15 @@ jobs: DISCORD_WEBHOOK_CANDIDATE: ${{ secrets.DISCORD_WEBHOOK_CANDIDATE }} DISCORD_WEBHOOK_STABLE: ${{ secrets.DISCORD_WEBHOOK_STABLE }} FLAVOR: ${{ inputs.flavor }} - with: result-encoding: string script: | - const ref = process.env.FLAVOR || "edge"; + const ref = process.env.FLAVOR || 'edge'; switch (ref) { - case "beta": return process.env.DISCORD_WEBHOOK_BETA; - case "candidate": return process.env.DISCORD_WEBHOOK_CANDIDATE; - case "stable": return process.env.DISCORD_WEBHOOK_STABLE; - case "edge": + case 'beta': return process.env.DISCORD_WEBHOOK_BETA; + case 'candidate': return process.env.DISCORD_WEBHOOK_CANDIDATE; + case 'stable': return process.env.DISCORD_WEBHOOK_STABLE; + case 'edge': default: return process.env.DISCORD_WEBHOOK_EDGE; } @@ -303,5 +278,5 @@ jobs: avatar_url: https://raw.githubusercontent.com/JagandeepBrar/LunaSea/master/assets/icon/icon.png noprefix: true color: 0x4ECCA3 - title: ${{ inputs.build_title }} - description: '[Download](https://builds.lunasea.app/#${{ inputs.build_title }}/)' + title: ${{ inputs.build-title }} + description: '[Download](https://builds.lunasea.app/#${{ inputs.build-title }}/)' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddaa0226e5..c3eb14e49b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,23 +43,23 @@ jobs: secrets: FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} - build_android: + build-android: name: Build Android needs: [ prepare, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/build_android.yml@master with: - build_number: ${{ needs.prepare.outputs.build_number }} + build-number: ${{ needs.prepare.outputs.build-number }} secrets: FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} KEY_JKS: ${{ secrets.KEY_JKS }} KEY_PROPERTIES: ${{ secrets.KEY_PROPERTIES }} - build_ios: + build-ios: name: Build iOS needs: [ prepare, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/build_ios.yml@master with: - build_number: ${{ needs.prepare.outputs.build_number }} + build-number: ${{ needs.prepare.outputs.build-number }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} @@ -70,27 +70,26 @@ jobs: MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_SSH_PRIVATE_KEY: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - build_linux: + build-linux: name: Build Linux needs: [ prepare, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/build_linux.yml@master with: - build_number: ${{ needs.prepare.outputs.build_number }} + build-number: ${{ needs.prepare.outputs.build-number }} secrets: FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} - build_macos: + build-macos: name: Build macOS needs: [ prepare, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/build_macos.yml@master with: - build_number: ${{ needs.prepare.outputs.build_number }} + build-number: ${{ needs.prepare.outputs.build-number }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} APPLE_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} APPLE_STORE_CONNECT_KEY: ${{ secrets.APPLE_STORE_CONNECT_KEY }} - APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} @@ -99,28 +98,27 @@ jobs: MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_SSH_PRIVATE_KEY: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} - build_web: + build-web: name: Build Web needs: [ prepare, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/build_web.yml@master with: - build_number: ${{ needs.prepare.outputs.build_number }} + build-number: ${{ needs.prepare.outputs.build-number }} secrets: FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} publish: name: Publish - needs: [ prepare, build_android, build_ios, build_linux, build_macos, build_web ] + needs: [ prepare, build-android, build-ios, build-linux, build-macos, build-web ] uses: JagandeepBrar/LunaSea/.github/workflows/publish.yml@master with: flavor: ${{ github.event.inputs.flavor || 'edge' }} - build_title: ${{ needs.prepare.outputs.build_title }} + build-title: ${{ needs.prepare.outputs.build-title }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} APPLE_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} APPLE_STORE_CONNECT_KEY: ${{ secrets.APPLE_STORE_CONNECT_KEY }} - APPLE_STORE_CONNECT_KEY_FILEPATH: ${{ secrets.APPLE_STORE_CONNECT_KEY_FILEPATH }} APPLE_STORE_CONNECT_KEY_ID: ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} DISCORD_WEBHOOK_EDGE: ${{ secrets.DISCORD_WEBHOOK_EDGE }} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index a223004d26..4479811c6b 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -11,26 +11,12 @@ jobs: name: Analyze runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Install Core Files - uses: actions/download-artifact@v3 + - name: Setup Environment + uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master with: - name: core_files + platform: test + firebase-options: ${{ secrets.FIREBASE_OPTIONS }} - - name: Install Flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true - cache-key: ${{ github.sha }} - - - name: Prepare Analysis - run: | - echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > lib/firebase_options.dart - flutter pub get - - name: Analyze uses: invertase/github-action-dart-analyzer@v1 with: