Open History to see the last commit
1name: Mobile EAS Preview Build
2
3# One preview client and its build record, called per platform by
4# mobile-eas-preview.yml. The build job runs dependency and build scripts with a
5# read-only token. Only the record job, on a fresh runner that runs none of
6# them, gets the token that can push tags. The caller's concurrency group covers
7# both jobs, so a build queued for the same fingerprint starts after the tag exists.
8
9on:
10 workflow_call:
11 inputs:
12 platform:
13 description: android or ios
14 required: true
15 type: string
16 fingerprint:
17 required: true
18 type: string
19 secrets:
20 EXPO_PREVIEW_TOKEN:
21 required: true
22 outputs:
23 client:
24 description: Install link for the client with this fingerprint
25 value: ${{ jobs.android.outputs.client || jobs.ios.outputs.client }}
26
27permissions:
28 contents: read
29
30jobs:
31 android:
32 name: Build
33 if: inputs.platform == 'android'
34 runs-on: blacksmith-32vcpu-ubuntu-2404
35 timeout-minutes: 60
36 permissions:
37 contents: read
38 outputs:
39 client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
40 # Set only by a new build: the tag message, which is the install link.
41 record: ${{ steps.build.outputs.link }}
42 env:
43 APP_VARIANT: preview
44 NODE_OPTIONS: --max-old-space-size=8192
45 MOBILE_VERSION_POLICY: fingerprint
46 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
47 FINGERPRINT: ${{ inputs.fingerprint }}
48 BUILD_TAG: mobile-android-preview-build/${{ inputs.fingerprint }}
49 # Phones only: emulators use the development client from the native-client cache.
50 ORG_GRADLE_PROJECT_reactNativeArchitectures: armeabi-v7a,arm64-v8a
51 steps:
52 - name: Checkout
53 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
54 with:
55 fetch-depth: 0
56
57 - id: record
58 name: Check build record
59 run: |
60 if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
61 echo "built=true" >> "$GITHUB_OUTPUT"
62 echo "link=$(git tag -l --format='%(contents:subject)' "$BUILD_TAG")" >> "$GITHUB_OUTPUT"
63 fi
64
65 # The steps below run dependency and build scripts; they get no token.
66 - name: Drop checkout credentials
67 uses: ./.github/actions/drop-checkout-credentials
68
69 - name: Build
70 if: steps.record.outputs.built != 'true'
71 uses: ./.github/actions/eas-local-build
72 with:
73 platform: android
74 profile: preview:dev
75 environment: preview
76 expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
77 output: ${{ runner.temp }}/t3code-preview.apk
78
79 # `eas upload` hosts the APK on EAS and returns the page testers install from.
80 - id: build
81 name: Upload
82 if: steps.record.outputs.built != 'true'
83 working-directory: apps/mobile
84 shell: bash
85 run: |
86 eas upload --platform android --build-path "$RUNNER_TEMP/t3code-preview.apk" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
87 link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
88 if [ -z "$link" ]; then
89 echo "::error::eas upload returned no install link"
90 exit 1
91 fi
92 echo "link=$link" >> "$GITHUB_OUTPUT"
93 echo "### Android preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
94
95 ios:
96 name: Build
97 if: inputs.platform == 'ios'
98 runs-on: blacksmith-12vcpu-macos-27
99 timeout-minutes: 60
100 permissions:
101 contents: read
102 outputs:
103 client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
104 # Set only by a new build: the tag message, the install link and profile expiry.
105 record: ${{ steps.profile.outputs.record }}
106 env:
107 APP_VARIANT: preview
108 NODE_OPTIONS: --max-old-space-size=8192
109 MOBILE_VERSION_POLICY: fingerprint
110 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
111 FINGERPRINT: ${{ inputs.fingerprint }}
112 BUILD_TAG: mobile-ios-preview-build/${{ inputs.fingerprint }}
113 steps:
114 - name: Checkout
115 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
116 with:
117 fetch-depth: 0
118
119 - name: Setup Node
120 uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
121 with:
122 node-version-file: package.json
123
124 - id: record
125 name: Check build record
126 run: |
127 if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
128 link="$(git tag -l --format='%(contents)' "$BUILD_TAG" | node .github/scripts/mobile-ios-preview-record.cjs read)"
129 if [ -n "$link" ]; then
130 echo "built=true" >> "$GITHUB_OUTPUT"
131 echo "link=$link" >> "$GITHUB_OUTPUT"
132 fi
133 fi
134
135 # The steps below run dependency and build scripts; they get no token.
136 - name: Drop checkout credentials
137 uses: ./.github/actions/drop-checkout-credentials
138
139 - name: Build
140 if: steps.record.outputs.built != 'true'
141 uses: ./.github/actions/eas-local-build
142 with:
143 platform: ios
144 profile: preview:dev
145 environment: preview
146 expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
147 output: ${{ runner.temp }}/t3code-preview.ipa
148
149 # EAS hosts the signed client and returns its install page.
150 - id: build
151 name: Upload
152 if: steps.record.outputs.built != 'true'
153 working-directory: apps/mobile
154 shell: bash
155 run: |
156 eas upload --platform ios --build-path "$RUNNER_TEMP/t3code-preview.ipa" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
157 link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
158 if [ -z "$link" ]; then
159 echo "::error::eas upload returned no install link"
160 exit 1
161 fi
162 echo "link=$link" >> "$GITHUB_OUTPUT"
163 echo "### iOS preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
164
165 # The tag stores the install link and provisioning-profile expiry.
166 - id: profile
167 name: Read the provisioning profile
168 if: steps.record.outputs.built != 'true'
169 env:
170 LINK: ${{ steps.build.outputs.link }}
171 run: |
172 profile_path="$(unzip -Z -1 "$RUNNER_TEMP/t3code-preview.ipa" | grep -E '^Payload/[^/]+\.app/embedded\.mobileprovision$')"
173 unzip -p "$RUNNER_TEMP/t3code-preview.ipa" "$profile_path" > "$RUNNER_TEMP/preview.mobileprovision"
174 security cms -D -i "$RUNNER_TEMP/preview.mobileprovision" > "$RUNNER_TEMP/preview-profile.plist"
175 record="$(node .github/scripts/mobile-ios-preview-record.cjs create "$LINK" "$RUNNER_TEMP/preview-profile.plist")"
176 echo "record=$record" >> "$GITHUB_OUTPUT"
177
178 # The tag is the record later runs look up. Android's message is the install
179 # link and is never replaced; iOS replaces an expired record for the fingerprint.
180 record:
181 name: Record build
182 needs: [android, ios]
183 if: ${{ !cancelled() && (needs.android.outputs.record != '' || needs.ios.outputs.record != '') }}
184 runs-on: blacksmith-2vcpu-ubuntu-2404
185 timeout-minutes: 5
186 permissions:
187 contents: write # pushes the build record tag
188 steps:
189 # The commit the build job built. No build ran in this checkout.
190 - name: Checkout
191 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
192 with:
193 fetch-depth: 0
194
195 - name: Record build
196 uses: ./.github/actions/record-build-tag
197 with:
198 tag: mobile-${{ inputs.platform }}-preview-build/${{ inputs.fingerprint }}
199 message: ${{ needs.android.outputs.record || needs.ios.outputs.record }}
200 replace: ${{ inputs.platform == 'ios' }}
201 token: ${{ github.token }}