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