|
| 1 | +name: Build Android |
| 2 | + |
| 3 | +# Creates a temp branch, bumps version (build.yml), builds the Android APK/AAB. |
| 4 | +# Mirrors build-and-upload-to-testflight.yml but Android-only and without the upload step. |
| 5 | +# APK/AAB artifacts stay attached to the build.yml run via its existing Upload Android * steps. |
| 6 | +# |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + source_branch: |
| 11 | + description: 'Branch, tag, or SHA to build' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + environment: |
| 15 | + description: 'Build environment / track. Must be one of: exp, beta, rc (enforced by validate-inputs).' |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + upload_to_sentry: |
| 19 | + description: 'If true, enable Sentry CLI upload of JS source maps and native debug symbols during the build' |
| 20 | + required: false |
| 21 | + type: boolean |
| 22 | + default: false |
| 23 | + runner_provider: |
| 24 | + description: Runner provider forwarded from the caller |
| 25 | + required: false |
| 26 | + type: string |
| 27 | + default: current |
| 28 | + outputs: |
| 29 | + build_branch: |
| 30 | + description: 'Ephemeral build branch created from source_branch' |
| 31 | + value: ${{ jobs.prepare-build-branch.outputs.build_branch }} |
| 32 | + built_commit_sha: |
| 33 | + description: 'Resolved commit SHA at the version-bump commit after build succeeded' |
| 34 | + value: ${{ jobs.build.outputs.built_commit_sha }} |
| 35 | + semantic_version: |
| 36 | + description: 'package.json version at the built commit' |
| 37 | + value: ${{ jobs.build.outputs.semantic_version }} |
| 38 | + android_version_code: |
| 39 | + description: 'android/app/build.gradle versionCode at the built commit' |
| 40 | + value: ${{ jobs.build.outputs.android_version_code }} |
| 41 | + workflow_dispatch: |
| 42 | + inputs: |
| 43 | + source_branch: |
| 44 | + description: 'Branch, tag, or SHA to build' |
| 45 | + required: true |
| 46 | + type: string |
| 47 | + default: 'main' |
| 48 | + environment: |
| 49 | + description: 'Build environment / track' |
| 50 | + required: true |
| 51 | + type: choice |
| 52 | + options: |
| 53 | + - exp |
| 54 | + - beta |
| 55 | + - rc |
| 56 | + default: rc |
| 57 | + upload_to_sentry: |
| 58 | + description: 'Upload JS source maps and native debug symbols to Sentry during the build (requires Sentry auth in the build environment)' |
| 59 | + required: false |
| 60 | + type: boolean |
| 61 | + default: false |
| 62 | + runner_provider: |
| 63 | + description: Runner provider for this manual trial run |
| 64 | + required: false |
| 65 | + type: choice |
| 66 | + options: |
| 67 | + - current |
| 68 | + - namespace |
| 69 | + default: current |
| 70 | + |
| 71 | +permissions: |
| 72 | + contents: write |
| 73 | + id-token: write |
| 74 | + |
| 75 | +jobs: |
| 76 | + # workflow_call inputs cannot use `type: choice` in GitHub Actions, so we enforce |
| 77 | + # the allowed `environment` values at runtime to prevent other workflows from |
| 78 | + # invoking this wrapper with arbitrary build tracks. |
| 79 | + validate-inputs: |
| 80 | + name: Validate inputs |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - name: Validate environment input |
| 84 | + env: |
| 85 | + ENVIRONMENT: ${{ inputs.environment }} |
| 86 | + run: | |
| 87 | + case "$ENVIRONMENT" in |
| 88 | + exp|beta|rc) echo "✅ environment=$ENVIRONMENT is allowed" ;; |
| 89 | + *) echo "::error::Invalid environment '$ENVIRONMENT'. Must be one of: exp, beta, rc"; exit 1 ;; |
| 90 | + esac |
| 91 | +
|
| 92 | + prepare-build-branch: |
| 93 | + needs: [validate-inputs] |
| 94 | + uses: ./.github/workflows/create-build-branch.yml |
| 95 | + with: |
| 96 | + source_branch: ${{ inputs.source_branch }} |
| 97 | + secrets: inherit |
| 98 | + |
| 99 | + build: |
| 100 | + name: Build Android (${{ inputs.environment }}) |
| 101 | + needs: [prepare-build-branch] |
| 102 | + uses: ./.github/workflows/build.yml |
| 103 | + with: |
| 104 | + build_name: main-${{ inputs.environment }} |
| 105 | + platform: android |
| 106 | + skip_version_bump: false |
| 107 | + source_branch: ${{ needs.prepare-build-branch.outputs.build_branch }} |
| 108 | + upload_to_sentry: ${{ inputs.upload_to_sentry }} |
| 109 | + runner_provider: ${{ inputs.runner_provider }} |
| 110 | + secrets: inherit |
| 111 | + |
| 112 | + cleanup-build-branch: |
| 113 | + name: Cleanup build branch |
| 114 | + needs: [prepare-build-branch, build] |
| 115 | + if: always() |
| 116 | + runs-on: ${{ inputs.runner_provider == 'namespace' && 'namespace-profile-metamask-ci-linux' || 'ubuntu-latest' }} |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v4 |
| 119 | + with: |
| 120 | + token: ${{ secrets.PR_TOKEN || github.token }} |
| 121 | + - name: Delete temporary build branch |
| 122 | + env: |
| 123 | + BRANCH: ${{ needs.prepare-build-branch.outputs.build_branch }} |
| 124 | + run: | |
| 125 | + if [ -n "$BRANCH" ]; then |
| 126 | + git push origin --delete "$BRANCH" || true |
| 127 | + echo "🧹 Deleted build branch: $BRANCH" |
| 128 | + fi |
0 commit comments