|
| 1 | +name: distribute_internal |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + platform: |
| 10 | + description: 'Platform to build (android, ios, or both)' |
| 11 | + required: true |
| 12 | + default: 'both' |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - android |
| 16 | + - ios |
| 17 | + - both |
| 18 | + |
| 19 | +env: |
| 20 | + FLUTTER_VERSION: '3.x' |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + determine_platforms: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + outputs: |
| 30 | + run_ios: ${{ steps.set_matrix.outputs.run_ios }} |
| 31 | + run_android: ${{ steps.set_matrix.outputs.run_android }} |
| 32 | + steps: |
| 33 | + - name: Determine platforms to build |
| 34 | + id: set_matrix |
| 35 | + run: | |
| 36 | + # Is this a branch push? |
| 37 | + is_branch_push="${{ github.event_name == 'push' }}" |
| 38 | + |
| 39 | + # If it's a branch push, build both platforms |
| 40 | + if [[ "$is_branch_push" == "true" ]]; then |
| 41 | + echo "Building all platforms due to branch push" |
| 42 | + echo "run_ios=true" >> $GITHUB_OUTPUT |
| 43 | + echo "run_android=true" >> $GITHUB_OUTPUT |
| 44 | + exit 0 |
| 45 | + fi |
| 46 | + |
| 47 | + # For manual workflow dispatch, store platform in a variable |
| 48 | + platform="${{ github.event.inputs.platform }}" |
| 49 | + echo "Selected platform: $platform" |
| 50 | + |
| 51 | + # Set outputs only if they should be true |
| 52 | + [[ "$platform" == "ios" || "$platform" == "both" ]] && echo "run_ios=true" >> $GITHUB_OUTPUT |
| 53 | + [[ "$platform" == "android" || "$platform" == "both" ]] && echo "run_android=true" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + android: |
| 56 | + needs: determine_platforms |
| 57 | + if: ${{ needs.determine_platforms.outputs.run_android == 'true' }} |
| 58 | + runs-on: ubuntu-latest |
| 59 | + timeout-minutes: 30 |
| 60 | + steps: |
| 61 | + - name: Connect Bot |
| 62 | + uses: webfactory/[email protected] |
| 63 | + with: |
| 64 | + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} |
| 65 | + |
| 66 | + - name: "Git Checkout" |
| 67 | + uses: actions/checkout@v4 |
| 68 | + with: |
| 69 | + fetch-depth: 0 |
| 70 | + |
| 71 | + - name: "Install Flutter" |
| 72 | + uses: subosito/flutter-action@v2 |
| 73 | + with: |
| 74 | + flutter-version: ${{ env.FLUTTER_VERSION }} |
| 75 | + channel: stable |
| 76 | + cache: true |
| 77 | + cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} |
| 78 | + |
| 79 | + - name: "Install Tools" |
| 80 | + run: flutter pub global activate melos |
| 81 | + |
| 82 | + - name: "Bootstrap Workspace" |
| 83 | + run: melos bootstrap |
| 84 | + |
| 85 | + - name: Setup Ruby |
| 86 | + uses: ruby/setup-ruby@v1 |
| 87 | + with: |
| 88 | + bundler-cache: true |
| 89 | + working-directory: sample_app/android |
| 90 | + |
| 91 | + - name: Setup Firebase Service Account' |
| 92 | + working-directory: sample_app/android |
| 93 | + run: echo "${{ secrets.SAMPLE_FIREBASE_UPLOAD_CREDENTIALS }}" | base64 --decode | jq > ./firebase-service-account.json |
| 94 | + |
| 95 | + - name: Distribute to Firebase |
| 96 | + working-directory: sample_app/android |
| 97 | + run: bundle exec fastlane distribute_to_firebase |
| 98 | + |
| 99 | + ios: |
| 100 | + needs: determine_platforms |
| 101 | + if: ${{ needs.determine_platforms.outputs.run_ios == 'true' }} |
| 102 | + runs-on: macos-latest |
| 103 | + timeout-minutes: 30 |
| 104 | + steps: |
| 105 | + - name: Connect Bot |
| 106 | + uses: webfactory/[email protected] |
| 107 | + with: |
| 108 | + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} |
| 109 | + |
| 110 | + - name: "Git Checkout" |
| 111 | + uses: actions/checkout@v4 |
| 112 | + with: |
| 113 | + fetch-depth: 0 |
| 114 | + |
| 115 | + - name: "Install Flutter" |
| 116 | + uses: subosito/flutter-action@v2 |
| 117 | + with: |
| 118 | + flutter-version: ${{ env.FLUTTER_VERSION }} |
| 119 | + channel: stable |
| 120 | + cache: true |
| 121 | + cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} |
| 122 | + |
| 123 | + - name: "Install Tools" |
| 124 | + run: flutter pub global activate melos |
| 125 | + |
| 126 | + - name: "Bootstrap Workspace" |
| 127 | + run: melos bootstrap |
| 128 | + |
| 129 | + - name: Setup Ruby |
| 130 | + uses: ruby/setup-ruby@v1 |
| 131 | + with: |
| 132 | + bundler-cache: true |
| 133 | + working-directory: sample_app/ios |
| 134 | + |
| 135 | + - name: Setup Firebase Service Account |
| 136 | + working-directory: sample_app/ios |
| 137 | + run: echo "${{ secrets.SAMPLE_FIREBASE_UPLOAD_CREDENTIALS }}" | base64 --decode | jq > ./firebase-service-account.json |
| 138 | + |
| 139 | + - name: Distribute to Firebase |
| 140 | + working-directory: sample_app/ios |
| 141 | + env: |
| 142 | + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} |
| 143 | + APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }} |
| 144 | + run: bundle exec fastlane distribute_to_firebase |
0 commit comments