diff --git a/.github/workflows/prepare.yml b/.github/workflows/prepare.yml deleted file mode 100644 index 40e179de..00000000 --- a/.github/workflows/prepare.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Prepare - -on: - workflow_call: - inputs: - ref: - type: string - required: true - - outputs: - flavor: - description: "Build Flavor Environment (internal, alpha, beta, production)" - value: ${{ jobs.flavor.outputs.output1 }} - track: - description: "Track Name (Develop, Alpha, Beta, Production)" - value: ${{ jobs.flavor.outputs.output2 }} - -jobs: - flavor: - name: Flavor - runs-on: ubuntu-latest - outputs: - output1: ${{ steps.output.outputs.flavor }} - output2: ${{ steps.output.outputs.track }} - steps: - - name: Determine Flavor - id: determine_flavor - uses: actions/github-script@v5 - env: - FLAVOR: ${{ inputs.ref }} - with: - result-encoding: string - script: | - const ref = process.env.FLAVOR || 'internal'; - switch (ref) { - case "alpha": return "alpha"; - case "beta": return "beta"; - case "production": return "production"; - default: return "internal"; - } - - - name: Determine Track - id: determine_track - uses: actions/github-script@v5 - env: - FLAVOR: ${{ inputs.ref }} - with: - result-encoding: string - script: | - const ref = process.env.FLAVOR || 'internal'; - switch (ref) { - case "alpha": return "Alpha"; - case "beta": return "Beta"; - case "production": return "Production"; - default: return "Develop"; - } - - - name: Set Flavor Output - id: output - run: | - echo "::set-output name=flavor::${{ steps.determine_flavor.outputs.result }}" - echo "::set-output name=track::${{ steps.determine_track.outputs.result }}" - - - name: Create Flavor Configuration - working-directory: ${{ github.workspace }} - run: | - echo FLAVOR=${{ steps.determine_flavor.outputs.result }} - echo TRACK=${{ steps.determine_track.outputs.result }} - echo COMMIT=${{ github.sha }} - echo $'FLAVOR=${{ steps.determine_flavor.outputs.result }}\nCOMMIT=${{ github.sha }}' > .flavor - - - name: Upload Flavor Configuration - uses: actions/upload-artifact@v2 - with: - name: flavor-${{ github.sha }} - path: ${{ github.workspace }}/.flavor diff --git a/.github/workflows/prepare_build.yml b/.github/workflows/prepare_build.yml new file mode 100644 index 00000000..a8d485de --- /dev/null +++ b/.github/workflows/prepare_build.yml @@ -0,0 +1,92 @@ +name: Prepare Build + +on: + workflow_call: + inputs: + ref: + type: string + required: true + + outputs: + flavor: + description: "Build Flavor" + value: ${{ jobs.flavor.outputs.output1 }} + number: + description: "Build Number" + value: ${{ jobs.number.outputs.output1 }} + +jobs: + flavor: + name: Flavor + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.output.outputs.flavor }} + steps: + - name: Run Script + id: script + uses: actions/github-script@v6 + env: + FLAVOR: ${{ inputs.ref }} + with: + result-encoding: string + script: | + const ref = process.env.FLAVOR || "edge"; + switch (ref) { + case "beta": return "beta"; + case "candidate": return "candidate"; + case "stable": return "stable"; + default: return "edge"; + } + + - name: Set Output + id: output + run: | + echo ${{ steps.script.outputs.result }} + echo "::set-output name=flavor::${{ steps.script.outputs.result }}" + + - name: Create Flavor Configuration + working-directory: ${{ github.workspace }} + run: | + echo $'FLAVOR=${{ steps.script.outputs.result }}\nCOMMIT=${{ github.sha }}' > .flavor + + - name: Upload Flavor Configuration + uses: actions/upload-artifact@v2 + with: + name: flavor-${{ github.sha }} + path: ${{ github.workspace }}/.flavor + + number: + name: Number + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.output.outputs.number }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Count Commits + id: commit_count + run: | + count=`git rev-list HEAD --count` + echo "::set-output name=commit_count::$count" + + - name: Run Script + id: script + uses: actions/github-script@v6 + env: + FLAVOR: ${{ inputs.ref }} + COUNT: ${{ steps.commit_count.outputs.commit_count }} + with: + result-encoding: string + script: | + const count = process.env.COUNT || 0; + const base = 1000000000; + return base + count; + + - name: Set Output + id: output + run: | + echo ${{ steps.script.outputs.result }} + echo "::set-output name=number::${{ steps.script.outputs.result }}" diff --git a/.github/workflows/prepare_channels.yml b/.github/workflows/prepare_channels.yml new file mode 100644 index 00000000..66158403 --- /dev/null +++ b/.github/workflows/prepare_channels.yml @@ -0,0 +1,139 @@ +name: Prepare Channels + +on: + workflow_call: + inputs: + ref: + type: string + required: true + + outputs: + android: + description: "Android Deployment Channel" + value: ${{ jobs.android.outputs.output1 }} + ios: + description: "iOS Deployment Channel" + value: ${{ jobs.ios.outputs.output1 }} + linux: + description: "Linux Deployment Channel" + value: ${{ jobs.linux.outputs.output1 }} + macos: + description: "macOS Deployment Channel" + value: ${{ jobs.macos.outputs.output1 }} + +jobs: + android: + name: Android + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.output.outputs.channel }} + steps: + - name: Run Script + id: script + uses: actions/github-script@v6 + env: + FLAVOR: ${{ inputs.ref }} + with: + result-encoding: string + script: | + 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"; + } + + - name: Set Output + id: output + run: | + echo ${{ steps.script.outputs.result }} + echo "::set-output name=channel::${{ steps.script.outputs.result }}" + + ios: + name: iOS + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.output.outputs.channel }} + steps: + - name: Run Script + id: script + uses: actions/github-script@v6 + env: + FLAVOR: ${{ inputs.ref }} + with: + result-encoding: string + script: | + const ref = process.env.FLAVOR || "edge"; + switch (ref) { + case "beta": return "beta"; + case "candidate": return "candidate"; + case "stable": return "stable"; + case "edge": + default: return "edge"; + } + + - name: Set Output + id: output + run: | + echo ${{ steps.script.outputs.result }} + echo "::set-output name=channel::${{ steps.script.outputs.result }}" + + linux: + name: Linux + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.output.outputs.channel }} + steps: + - name: Run Script + id: script + uses: actions/github-script@v6 + env: + FLAVOR: ${{ inputs.ref }} + with: + result-encoding: string + script: | + const ref = process.env.FLAVOR || "edge"; + switch (ref) { + case "beta": return "beta"; + case "candidate": return "candidate"; + case "stable": return "stable"; + case "edge": + default: return "edge"; + } + + - name: Set Output + id: output + run: | + echo ${{ steps.script.outputs.result }} + echo "::set-output name=channel::${{ steps.script.outputs.result }}" + + macos: + name: macOS + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.output.outputs.channel }} + steps: + - name: Run Script + id: script + uses: actions/github-script@v6 + env: + FLAVOR: ${{ inputs.ref }} + with: + result-encoding: string + script: | + const ref = process.env.FLAVOR || "edge"; + switch (ref) { + case "beta": return "beta"; + case "candidate": return "candidate"; + case "stable": return "stable"; + case "edge": + default: return "edge"; + } + + - name: Set Output + id: output + run: | + echo ${{ steps.script.outputs.result }} + echo "::set-output name=channel::${{ steps.script.outputs.result }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e86f10b..c1dede6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,14 +7,15 @@ on: workflow_dispatch: inputs: flavor: - description: Build Flavour + description: Build Flavor required: true - default: alpha + default: edge type: choice options: - - alpha + - edge - beta - - production + - candidate + - stable jobs: cancel: @@ -26,16 +27,23 @@ jobs: with: access_token: ${{ github.token }} - prepare: - name: Prepare + prepare_build: + name: Prepare Build needs: [ cancel ] - uses: JagandeepBrar/LunaSea/.github/workflows/prepare.yml@master + uses: JagandeepBrar/LunaSea/.github/workflows/prepare_build.yml@master + with: + ref: ${{ github.event.inputs.flavor }} + + prepare_channels: + name: Prepare Channels + needs: [ cancel ] + uses: JagandeepBrar/LunaSea/.github/workflows/prepare_channels.yml@master with: ref: ${{ github.event.inputs.flavor }} generate_files: name: Generate - needs: [ prepare ] + needs: [ prepare_build ] uses: JagandeepBrar/LunaSea/.github/workflows/generate_files.yml@master secrets: FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} @@ -49,11 +57,12 @@ jobs: android: name: Android - needs: [ prepare, validate ] + needs: [ prepare_build, prepare_channels, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/release_android.yml@master with: - flavor: ${{ needs.prepare.outputs.flavor }} - track: ${{ needs.prepare.outputs.track }} + build_flavor: ${{ needs.prepare_build.outputs.build_flavor }} + build_number: ${{ needs.prepare_build.outputs.build_number }} + channel: ${{ needs.prepare_channels.outputs.android }} secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} @@ -63,11 +72,12 @@ jobs: ios: name: iOS - needs: [ prepare, validate ] + needs: [ prepare_build, prepare_channels, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/release_ios.yml@master with: - flavor: ${{ needs.prepare.outputs.flavor }} - track: ${{ needs.prepare.outputs.track }} + build_flavor: ${{ needs.prepare_build.outputs.build_flavor }} + build_number: ${{ needs.prepare_build.outputs.build_number }} + channel: ${{ needs.prepare_channels.outputs.ios }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} @@ -85,11 +95,12 @@ jobs: macos: name: macOS - needs: [ prepare, validate ] + needs: [ prepare_build, prepare_channels, validate ] uses: JagandeepBrar/LunaSea/.github/workflows/release_macos.yml@master with: - flavor: ${{ needs.prepare.outputs.flavor }} - track: ${{ needs.prepare.outputs.track }} + build_flavor: ${{ needs.prepare_build.outputs.build_flavor }} + build_number: ${{ needs.prepare_build.outputs.build_number }} + channel: ${{ needs.prepare_channels.outputs.macos }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} @@ -107,12 +118,12 @@ jobs: web: name: Web - needs: [ prepare, validate ] - if: ${{ needs.prepare.outputs.flavor == 'internal' }} + needs: [ prepare_build, prepare_channels, validate ] + if: ${{ needs.prepare.outputs.build_flavor == 'edge' }} uses: JagandeepBrar/LunaSea/.github/workflows/release_web.yml@master with: - flavor: ${{ needs.prepare.outputs.flavor }} - track: ${{ needs.prepare.outputs.track }} + build_flavor: ${{ needs.prepare_build.outputs.build_flavor }} + build_number: ${{ needs.prepare_build.outputs.build_number }} secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} diff --git a/.github/workflows/release_android.yml b/.github/workflows/release_android.yml index e56f4af0..a4c9f95c 100644 --- a/.github/workflows/release_android.yml +++ b/.github/workflows/release_android.yml @@ -3,10 +3,13 @@ name: '[Release] Android' on: workflow_call: inputs: - flavor: + build_flavor: required: true type: string - track: + build_number: + required: true + type: string + channel: required: true type: string @@ -85,7 +88,7 @@ jobs: - name: Upload App Bundle Artifact uses: actions/upload-artifact@v2 with: - name: android-${{ inputs.flavor }}-${{ github.sha }} + name: android-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }}/build/app/outputs/bundle/release/app-release.aab - name: Send Discord Message @@ -94,8 +97,8 @@ jobs: env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} with: - title: '`[${{ inputs.track }}]` Android Build' - description: android-${{ inputs.flavor }}-${{ github.sha }} + title: '`[${{ inputs.build_flavor }}]` Android Build' + description: android-${{ inputs.build_flavor }}-${{ github.sha }} deploy: name: Deploy @@ -108,7 +111,7 @@ jobs: - name: Download App Package Artifact uses: actions/download-artifact@v2 with: - name: android-${{ inputs.flavor }}-${{ github.sha }} + name: android-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }} - name: Install Secret Keys @@ -127,13 +130,4 @@ jobs: SUPPLY_JSON_KEY: ${{ github.workspace }}/.fastlane-android-auth.json run: | bundle install - bundle exec fastlane deploy track:${{ inputs.flavor }} aab:${{ github.workspace }}/app-release.aab version_name:${{ github.sha }} - - - name: Send Discord Message - uses: sarisia/actions-status-discord@v1 - if: always() - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - with: - title: '`[${{ inputs.track }}]` Android Deployment' - description: android-${{ inputs.flavor }}-${{ github.sha }} + bundle exec fastlane deploy track:${{ inputs.channel }} aab:${{ github.workspace }}/app-release.aab version_name:${{ github.sha }} build_number:${{ inputs.build_number }} diff --git a/.github/workflows/release_ios.yml b/.github/workflows/release_ios.yml index 5ffa81a5..09596972 100644 --- a/.github/workflows/release_ios.yml +++ b/.github/workflows/release_ios.yml @@ -3,10 +3,13 @@ name: '[Release] iOS' on: workflow_call: inputs: - flavor: + build_flavor: required: true type: string - track: + build_number: + required: true + type: string + channel: required: true type: string @@ -113,7 +116,7 @@ jobs: - name: Upload App Package Artifact uses: actions/upload-artifact@v2 with: - name: ios-${{ inputs.flavor }}-${{ github.sha }} + name: ios-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }}/ios/Runner.ipa - name: Send Discord Message @@ -122,8 +125,8 @@ jobs: env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} with: - title: '`[${{ inputs.track }}]` iOS Build' - description: ios-${{ inputs.flavor }}-${{ github.sha }} + title: '`[${{ inputs.build_flavor }}]` iOS Build' + description: ios-${{ inputs.build_flavor }}-${{ github.sha }} deploy: name: Deploy @@ -136,7 +139,7 @@ jobs: - name: Download App Package Artifact uses: actions/download-artifact@v2 with: - name: ios-${{ inputs.flavor }}-${{ github.sha }} + name: ios-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }} - name: Install Secret Keys @@ -160,13 +163,4 @@ jobs: APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | bundle install - bundle exec fastlane deploy groups:${{ inputs.flavor }} ipa:${{ github.workspace }}/Runner.ipa - - - name: Send Discord Message - uses: sarisia/actions-status-discord@v1 - if: always() - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - with: - title: '`[${{ inputs.track }}]` iOS Deployment' - description: ios-${{ inputs.flavor }}-${{ github.sha }} + bundle exec fastlane deploy groups:${{ inputs.channel }} ipa:${{ github.workspace }}/Runner.ipa build_number:${{ inputs.build_number }} diff --git a/.github/workflows/release_macos.yml b/.github/workflows/release_macos.yml index 55aeb22c..211df13c 100644 --- a/.github/workflows/release_macos.yml +++ b/.github/workflows/release_macos.yml @@ -3,10 +3,13 @@ name: '[Release] macOS' on: workflow_call: inputs: - flavor: + build_flavor: required: true type: string - track: + build_number: + required: true + type: string + channel: required: true type: string @@ -114,7 +117,7 @@ jobs: - name: Upload App Package Artifact uses: actions/upload-artifact@v2 with: - name: macos-${{ inputs.flavor }}-${{ github.sha }} + name: macos-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }}/macos/LunaSea.pkg - name: Send Discord Message @@ -123,8 +126,8 @@ jobs: env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} with: - title: '`[${{ inputs.track }}]` macOS Build' - description: macos-${{ inputs.flavor }}-${{ github.sha }} + title: '`[${{ inputs.build_flavor }}]` macOS Build' + description: macos-${{ inputs.build_flavor }}-${{ github.sha }} deploy: name: Deploy @@ -137,7 +140,7 @@ jobs: - name: Download App Package Artifact uses: actions/download-artifact@v2 with: - name: macos-${{ inputs.flavor }}-${{ github.sha }} + name: macos-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }} - name: Install Secret Keys @@ -161,13 +164,4 @@ jobs: APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | bundle install - bundle exec fastlane deploy groups:${{ inputs.flavor }} pkg:${{ github.workspace }}/LunaSea.pkg - - - name: Send Discord Message - uses: sarisia/actions-status-discord@v1 - if: always() - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - with: - title: '`[${{ inputs.track }}]` macOS Deployment' - description: macos-${{ inputs.flavor }}-${{ github.sha }} + bundle exec fastlane deploy groups:${{ inputs.channel }} pkg:${{ github.workspace }}/LunaSea.pkg build_number:${{ inputs.build_number }} diff --git a/.github/workflows/release_web.yml b/.github/workflows/release_web.yml index da9559fb..8293db41 100644 --- a/.github/workflows/release_web.yml +++ b/.github/workflows/release_web.yml @@ -3,10 +3,10 @@ name: '[Release] Web' on: workflow_call: inputs: - flavor: + build_flavor: required: true type: string - track: + build_number: required: true type: string @@ -58,12 +58,12 @@ jobs: - name: Build LunaSea working-directory: ${{ github.workspace }} run: | - flutter build web --web-renderer canvaskit --release + flutter build web --web-renderer canvaskit --release --build-number=${{ inputs.build_number }} - name: Upload Web Build Artifact uses: actions/upload-artifact@v2 with: - name: web-${{ inputs.flavor }}-${{ github.sha }} + name: web-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }}/build/web - name: Send Discord Message @@ -72,8 +72,8 @@ jobs: env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} with: - title: '`[${{ inputs.track }}]` Web Build' - description: web-${{ inputs.flavor }}-${{ github.sha }} + title: '`[${{ inputs.build_flavor }}]` Web Build' + description: web-${{ inputs.build_flavor }}-${{ github.sha }} deploy: name: Deploy @@ -86,7 +86,7 @@ jobs: - name: Download Web Build Artifact uses: actions/download-artifact@v2 with: - name: web-${{ inputs.flavor }}-${{ github.sha }} + name: web-${{ inputs.build_flavor }}-${{ github.sha }} path: ${{ github.workspace }}/build/web - name: Deploy to GitHub Pages @@ -98,12 +98,3 @@ jobs: clean: true clean-exclude: | CNAME - - - name: Send Discord Message - uses: sarisia/actions-status-discord@v1 - if: always() - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - with: - title: '`[${{ inputs.track }}]` Web Deployment' - description: web-${{ inputs.flavor }}-${{ github.sha }} diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index e8e08c56..f5448b25 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -1,10 +1,9 @@ default_platform(:android) -build_number = 1000000000 + number_of_commits() platform :android do desc "Build App Bundle" - lane :build do - sh("flutter", "build", "appbundle", "--release", "--bundle-sksl-path=shaders/android_sksl.json", "--build-number=#{build_number}") + lane :build do |options| + sh("flutter", "build", "appbundle", "--release", "--bundle-sksl-path=shaders/android_sksl.json", "--build-number=#{options[:build_number]}") end desc "Deploy to Google Play Store" @@ -15,7 +14,7 @@ platform :android do skip_upload_images: true, skip_upload_screenshots: true, track: options[:track] || "internal", - version_name: options[:version_name] || "#{build_number}", + version_name: options[:version_name] || "Unknown Version", ) end diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index a0dbb563..292d1895 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -1,5 +1,4 @@ default_platform(:ios) -build_number = 1000000000 + number_of_commits() platform :ios do desc "Setup the LunaSea Keychain" @@ -36,7 +35,7 @@ platform :ios do end desc "Build App Package" - lane :build do + lane :build do |options| prepare_keychain sh( @@ -44,7 +43,7 @@ platform :ios do "--release", "--bundle-sksl-path=shaders/ios_sksl.json", "--no-codesign", - "--build-number=#{build_number}", + "--build-number=#{options[:build_number]}", ) build_ios_app( scheme: "Runner", diff --git a/macos/fastlane/Fastfile b/macos/fastlane/Fastfile index a6517d29..c497e637 100644 --- a/macos/fastlane/Fastfile +++ b/macos/fastlane/Fastfile @@ -1,5 +1,4 @@ default_platform(:mac) -build_number = 1000000000 + number_of_commits() platform :mac do desc "Setup the LunaSea Keychain" @@ -37,10 +36,22 @@ platform :mac do end desc "Build App Package" - lane :build do + lane :build do |options| prepare_keychain - sh("flutter", "build", "macos", "--release", "--build-number=#{build_number}") - build_mac_app(scheme: "Runner", workspace: "Runner.xcworkspace", export_method: "app-store") + + sh( + "flutter", + "build", + "macos", + "--release", + "--build-number=#{options[:build_number]}", + ) + build_mac_app( + scheme: "Runner", + workspace: "Runner.xcworkspace", + export_method: "app-store", + ) + destroy_keychain end