Skip to content

Commit b90a311

Browse files
ci(build): convert build.yml to workflow_call-only and add Build Android wrapper (#30270)
## Summary - Adds a new `build-android.yml` (`Build Android`) workflow that mirrors the structure of `build-and-upload-to-testflight.yml` but for Android APK/AAB: creates an ephemeral build branch, bumps the version via `build.yml`, builds the Android artifacts, and cleans up the branch. No upload step. - Adds runtime `validate-inputs` guards to both workflows to enforce the same closed sets that `workflow_dispatch` previously expressed via `type: choice` (since `workflow_call` inputs do not support `type: choice`). ## Changes ### `build-android.yml` (new) - `workflow_call` + `workflow_dispatch` triggers - Inputs: `source_branch` (required, "Branch, tag, or SHA to build"), `environment` (`exp`/`beta`/`rc`), `upload_to_sentry`, `runner_provider` - Outputs: `build_branch`, `built_commit_sha`, `semantic_version`, `android_version_code` - Jobs: `validate-inputs` → `prepare-build-branch` (create-build-branch.yml) → `build` (build.yml, platform: android) → `cleanup-build-branch` - APK/AAB artifacts are uploaded by the existing `Upload Android *` steps inside `build.yml`; no new artifact handling needed in the wrapper ## Callers unaffected All existing callers of `build.yml` (`nightly-build.yml`, `runway-rc-builds.yml`, `runway-production-builds.yml`, `expo-dev-build.yml`, `auto-rc-ota-build-core.yml`, `build-android-upload-to-browserstack.yml`, `build-ios-upload-to-browserstack.yml`, `build-and-upload-to-testflight.yml`) continue to work unchanged — they all use `workflow_call`. ## Manual testing - [ ] Trigger `Build Android` workflow manually from GitHub Actions UI with a valid branch and `environment: rc` - [ ] Verify `validate-inputs` fails fast with a clear error if an invalid `environment` or `build_name` is passed programmatically Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes CI workflow entrypoints and adds new runtime validation, which could break manual builds or callers if inputs/keys don’t match `builds.yml` or if `yq` isn’t available on runners. > > **Overview** > Adds a new `Build Android` workflow (`build-android.yml`) that can be manually triggered or called by other workflows to create an ephemeral build branch, run the existing reusable `build.yml` for Android (`main-exp/beta/rc`), and then delete the temporary branch. > > Updates `build.yml` to be `workflow_call`-only by removing its `workflow_dispatch` trigger and adding a fast-fail `validate-inputs` job that enforces allowed `platform`/`runner_provider` values and requires `build_name` to exist in `builds.yml` before running version bump/build steps. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 18b9790. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 801ab3f commit b90a311

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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

Comments
 (0)