@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
yml 454 lines 19.3 KB
Raw
1 name: Mobile EAS Preview
2
3 on:
4 pull_request:
5 types: [opened, reopened, synchronize, labeled]
6
7 jobs:
8 ios:
9 name: EAS Preview (iOS)
10 if: |
11 github.event.pull_request.head.repo.full_name == github.repository &&
12 contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment') &&
13 (github.event.action != 'labeled' || github.event.label.name == '🚀 Mobile Continuous Deployment')
14 runs-on: blacksmith-8vcpu-ubuntu-2404
15 concurrency:
16 group: mobile-eas-preview-ios-${{ github.event.pull_request.number }}
17 cancel-in-progress: true
18 permissions:
19 contents: read
20 pull-requests: write
21 outputs:
22 group: ${{ steps.update.outputs.group }}
23 client: ${{ steps.client.outputs.link }}
24 build: ${{ steps.client.outputs.build }}
25 fingerprint: ${{ steps.client.outputs.fingerprint }}
26 env:
27 APP_VARIANT: preview
28 NODE_OPTIONS: --max-old-space-size=8192
29 MOBILE_VERSION_POLICY: fingerprint
30 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
31 GH_TOKEN: ${{ github.token }}
32 PR: ${{ github.event.pull_request.number }}
33 steps:
34 - id: expo-token
35 name: Check for EXPO_PREVIEW_TOKEN
36 run: |
37 if [ -n "$EXPO_TOKEN" ]; then
38 echo "present=true" >> "$GITHUB_OUTPUT"
39 else
40 echo "present=false" >> "$GITHUB_OUTPUT"
41 echo "EXPO_PREVIEW_TOKEN is not available; skipping the iOS preview."
42 fi
43
44 - name: Checkout
45 if: steps.expo-token.outputs.present == 'true'
46 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
47 with:
48 fetch-depth: 0
49
50 # The steps below run dependency and build scripts; they get no token.
51 - name: Drop checkout credentials
52 if: steps.expo-token.outputs.present == 'true'
53 uses: ./.github/actions/drop-checkout-credentials
54
55 - name: Setup Vite+
56 if: steps.expo-token.outputs.present == 'true'
57 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
58 with:
59 node-version-file: package.json
60 cache: true
61 run-install: |
62 args:
63 - --filter=@t3tools/mobile...
64
65 - name: Expose pnpm
66 if: steps.expo-token.outputs.present == 'true'
67 run: |
68 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
69 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
70 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
71 "$vp_pnpm_bin/pnpm" --version
72
73 - name: Setup EAS
74 if: steps.expo-token.outputs.present == 'true'
75 uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
76 with:
77 eas-version: latest
78 token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
79 packager: npm
80
81 - name: Pull preview environment variables
82 if: steps.expo-token.outputs.present == 'true'
83 working-directory: apps/mobile
84 run: |
85 eas env:pull preview --non-interactive
86 node --input-type=module <<'NODE'
87 import { appendFileSync, readFileSync } from "node:fs";
88 import { parseEnv } from "node:util";
89 const env = parseEnv(readFileSync(".env.local", "utf8"));
90 const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
91 if (googleServicesFile) {
92 appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
93 }
94 NODE
95
96 # The same command the Expo action runs, so this is the runtime version the update gets.
97 - id: client
98 name: Find the client for this fingerprint
99 if: steps.expo-token.outputs.present == 'true'
100 working-directory: apps/mobile
101 shell: bash
102 run: |
103 hash="$(eas env:exec --non-interactive preview "npx expo-updates fingerprint:generate --platform ios" | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
104 echo "fingerprint=$hash" >> "$GITHUB_OUTPUT"
105 tag="mobile-ios-preview-build/$hash"
106 link=""
107 if git fetch --quiet origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null; then
108 link="$(git tag -l --format='%(contents)' "$tag" | node "$GITHUB_WORKSPACE/.github/scripts/mobile-ios-preview-record.cjs" read)"
109 fi
110 if [ -z "$link" ]; then
111 # A client EAS built before this job existed; expired ones are gone.
112 link="$(eas build:list --platform ios --build-profile preview:dev --runtime-version "$hash" --status finished --limit 5 --json --non-interactive \
113 | sed -n '/^\[/,$p' \
114 | jq -r --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '[.[] | select((.expirationDate // "9999") > $now)][0] | select(. != null) | "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/\(.id)"')"
115 fi
116 echo "link=$link" >> "$GITHUB_OUTPUT"
117 if [ -z "$link" ]; then echo "build=true" >> "$GITHUB_OUTPUT"; fi
118 echo "ios fingerprint \`$hash\`: ${link:-no client yet, building on Blacksmith}" >> "$GITHUB_STEP_SUMMARY"
119
120 - id: update
121 name: Publish the update
122 if: steps.expo-token.outputs.present == 'true'
123 working-directory: apps/mobile
124 shell: bash
125 run: |
126 group="$(eas update --auto --branch "pr-$PR" --platform ios --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"
127 echo "group=$group" >> "$GITHUB_OUTPUT"
128
129 # Preview build tags store the install link for each fingerprint; older EAS clients also count.
130 android:
131 name: EAS Preview (Android)
132 if: |
133 github.event.pull_request.head.repo.full_name == github.repository &&
134 contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment') &&
135 (github.event.action != 'labeled' || github.event.label.name == '🚀 Mobile Continuous Deployment')
136 runs-on: blacksmith-8vcpu-ubuntu-2404
137 concurrency:
138 group: mobile-eas-preview-android-${{ github.event.pull_request.number }}
139 cancel-in-progress: true
140 permissions:
141 contents: read
142 pull-requests: write
143 outputs:
144 group: ${{ steps.update.outputs.group }}
145 client: ${{ steps.client.outputs.link }}
146 build: ${{ steps.client.outputs.build }}
147 fingerprint: ${{ steps.client.outputs.fingerprint }}
148 env:
149 APP_VARIANT: preview
150 NODE_OPTIONS: --max-old-space-size=8192
151 MOBILE_VERSION_POLICY: fingerprint
152 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
153 GH_TOKEN: ${{ github.token }}
154 PR: ${{ github.event.pull_request.number }}
155 steps:
156 - id: expo-token
157 name: Check for EXPO_PREVIEW_TOKEN
158 run: |
159 if [ -n "$EXPO_TOKEN" ]; then
160 echo "present=true" >> "$GITHUB_OUTPUT"
161 else
162 echo "present=false" >> "$GITHUB_OUTPUT"
163 echo "EXPO_PREVIEW_TOKEN is not available; skipping the Android preview."
164 fi
165
166 - name: Checkout
167 if: steps.expo-token.outputs.present == 'true'
168 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
169 with:
170 fetch-depth: 0
171
172 # The steps below run dependency and build scripts; they get no token.
173 - name: Drop checkout credentials
174 if: steps.expo-token.outputs.present == 'true'
175 uses: ./.github/actions/drop-checkout-credentials
176
177 - name: Setup Vite+
178 if: steps.expo-token.outputs.present == 'true'
179 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
180 with:
181 node-version-file: package.json
182 cache: true
183 run-install: |
184 args:
185 - --filter=@t3tools/mobile...
186
187 - name: Expose pnpm
188 if: steps.expo-token.outputs.present == 'true'
189 run: |
190 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
191 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
192 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
193 "$vp_pnpm_bin/pnpm" --version
194
195 - name: Setup EAS
196 if: steps.expo-token.outputs.present == 'true'
197 uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
198 with:
199 eas-version: latest
200 token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
201 packager: npm
202
203 - name: Pull preview environment variables
204 if: steps.expo-token.outputs.present == 'true'
205 working-directory: apps/mobile
206 run: |
207 eas env:pull preview --non-interactive
208 node --input-type=module <<'NODE'
209 import { appendFileSync, readFileSync } from "node:fs";
210 import { parseEnv } from "node:util";
211 const env = parseEnv(readFileSync(".env.local", "utf8"));
212 const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
213 if (googleServicesFile) {
214 appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
215 }
216 NODE
217
218 # The same command the Expo action runs, so this is the runtime version the update gets.
219 - id: client
220 name: Find the client for this fingerprint
221 if: steps.expo-token.outputs.present == 'true'
222 working-directory: apps/mobile
223 shell: bash
224 run: |
225 hash="$(eas env:exec --non-interactive preview "npx expo-updates fingerprint:generate --platform android" | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
226 echo "fingerprint=$hash" >> "$GITHUB_OUTPUT"
227 tag="mobile-android-preview-build/$hash"
228 link=""
229 if git fetch --quiet origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null; then
230 link="$(git tag -l --format='%(contents:subject)' "$tag")"
231 else
232 # A client EAS built before this job existed; expired ones are gone.
233 link="$(eas build:list --platform android --build-profile preview:dev --runtime-version "$hash" --status finished --limit 5 --json --non-interactive \
234 | sed -n '/^\[/,$p' \
235 | jq -r --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '[.[] | select((.expirationDate // "9999") > $now)][0] | select(. != null) | "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/\(.id)"')"
236 fi
237 echo "link=$link" >> "$GITHUB_OUTPUT"
238 if [ -z "$link" ]; then echo "build=true" >> "$GITHUB_OUTPUT"; fi
239 echo "android fingerprint \`$hash\`: ${link:-no client yet, building on Blacksmith}" >> "$GITHUB_STEP_SUMMARY"
240
241 - id: update
242 name: Publish the update
243 if: steps.expo-token.outputs.present == 'true'
244 working-directory: apps/mobile
245 shell: bash
246 run: |
247 group="$(eas update --auto --branch "pr-$PR" --platform android --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"
248 echo "group=$group" >> "$GITHUB_OUTPUT"
249
250 android-build:
251 name: Android preview client
252 needs: android
253 if: needs.android.outputs.build == 'true'
254 runs-on: blacksmith-32vcpu-ubuntu-2404
255 timeout-minutes: 60
256 concurrency:
257 # One build per fingerprint; a second PR with the same one finds the tag.
258 group: mobile-android-preview-build-${{ needs.android.outputs.fingerprint }}
259 cancel-in-progress: false
260 queue: max
261 permissions:
262 contents: write # pushes the build record tag
263 pull-requests: write
264 outputs:
265 client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
266 env:
267 APP_VARIANT: preview
268 NODE_OPTIONS: --max-old-space-size=8192
269 MOBILE_VERSION_POLICY: fingerprint
270 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
271 FINGERPRINT: ${{ needs.android.outputs.fingerprint }}
272 BUILD_TAG: mobile-android-preview-build/${{ needs.android.outputs.fingerprint }}
273 # Phones only: emulators use the development client from the native-client cache.
274 ORG_GRADLE_PROJECT_reactNativeArchitectures: armeabi-v7a,arm64-v8a
275 steps:
276 - name: Checkout
277 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
278 with:
279 fetch-depth: 0
280
281 - id: record
282 name: Check build record
283 run: |
284 if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
285 echo "built=true" >> "$GITHUB_OUTPUT"
286 echo "link=$(git tag -l --format='%(contents:subject)' "$BUILD_TAG")" >> "$GITHUB_OUTPUT"
287 fi
288
289 # The steps below run dependency and build scripts; they get no token.
290 - name: Drop checkout credentials
291 uses: ./.github/actions/drop-checkout-credentials
292
293 - name: Build
294 if: steps.record.outputs.built != 'true'
295 uses: ./.github/actions/eas-local-build
296 with:
297 platform: android
298 profile: preview:dev
299 environment: preview
300 expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
301 output: ${{ runner.temp }}/t3code-preview.apk
302
303 # `eas upload` hosts the APK on EAS and returns the page testers install from.
304 - id: build
305 name: Upload
306 if: steps.record.outputs.built != 'true'
307 working-directory: apps/mobile
308 shell: bash
309 run: |
310 eas upload --platform android --build-path "$RUNNER_TEMP/t3code-preview.apk" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
311 link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
312 if [ -z "$link" ]; then
313 echo "::error::eas upload returned no install link"
314 exit 1
315 fi
316 echo "link=$link" >> "$GITHUB_OUTPUT"
317 echo "### Android preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
318
319 # The tag is the record later runs look up; its message is the install link.
320 - name: Record build
321 if: steps.record.outputs.built != 'true'
322 uses: ./.github/actions/record-build-tag
323 with:
324 tag: ${{ env.BUILD_TAG }}
325 message: ${{ steps.build.outputs.link }}
326 token: ${{ github.token }}
327
328 ios-build:
329 name: iOS preview client
330 needs: ios
331 if: needs.ios.outputs.build == 'true'
332 runs-on: blacksmith-12vcpu-macos-27
333 timeout-minutes: 60
334 concurrency:
335 # One build per fingerprint; a second PR with the same one finds the tag.
336 group: mobile-ios-preview-build-${{ needs.ios.outputs.fingerprint }}
337 cancel-in-progress: false
338 queue: max
339 permissions:
340 contents: write # pushes the build record tag
341 pull-requests: write
342 outputs:
343 client: ${{ steps.build.outputs.link || steps.record.outputs.link }}
344 env:
345 APP_VARIANT: preview
346 NODE_OPTIONS: --max-old-space-size=8192
347 MOBILE_VERSION_POLICY: fingerprint
348 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
349 FINGERPRINT: ${{ needs.ios.outputs.fingerprint }}
350 BUILD_TAG: mobile-ios-preview-build/${{ needs.ios.outputs.fingerprint }}
351 steps:
352 - name: Checkout
353 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
354 with:
355 fetch-depth: 0
356
357 - name: Setup Node
358 uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
359 with:
360 node-version-file: package.json
361
362 - id: record
363 name: Check build record
364 run: |
365 if git fetch --quiet origin "refs/tags/$BUILD_TAG:refs/tags/$BUILD_TAG" 2>/dev/null; then
366 link="$(git tag -l --format='%(contents)' "$BUILD_TAG" | node .github/scripts/mobile-ios-preview-record.cjs read)"
367 if [ -n "$link" ]; then
368 echo "built=true" >> "$GITHUB_OUTPUT"
369 echo "link=$link" >> "$GITHUB_OUTPUT"
370 fi
371 fi
372
373 # The steps below run dependency and build scripts; they get no token.
374 - name: Drop checkout credentials
375 uses: ./.github/actions/drop-checkout-credentials
376
377 - name: Build
378 if: steps.record.outputs.built != 'true'
379 uses: ./.github/actions/eas-local-build
380 with:
381 platform: ios
382 profile: preview:dev
383 environment: preview
384 expo-token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
385 output: ${{ runner.temp }}/t3code-preview.ipa
386
387 # EAS hosts the signed client and returns its install page.
388 - id: build
389 name: Upload
390 if: steps.record.outputs.built != 'true'
391 working-directory: apps/mobile
392 shell: bash
393 run: |
394 eas upload --platform ios --build-path "$RUNNER_TEMP/t3code-preview.ipa" --fingerprint "$FINGERPRINT" --non-interactive --json | tee "$RUNNER_TEMP/upload.json"
395 link="$(sed -n '/^{/,$p' "$RUNNER_TEMP/upload.json" | jq -r '.url // empty')"
396 if [ -z "$link" ]; then
397 echo "::error::eas upload returned no install link"
398 exit 1
399 fi
400 echo "link=$link" >> "$GITHUB_OUTPUT"
401 echo "### iOS preview client for \`$FINGERPRINT\`: $link" >> "$GITHUB_STEP_SUMMARY"
402
403 # The tag stores the install link and provisioning-profile expiry.
404 - id: profile
405 name: Read the provisioning profile
406 if: steps.record.outputs.built != 'true'
407 env:
408 LINK: ${{ steps.build.outputs.link }}
409 run: |
410 profile_path="$(unzip -Z -1 "$RUNNER_TEMP/t3code-preview.ipa" | grep -E '^Payload/[^/]+\.app/embedded\.mobileprovision$')"
411 unzip -p "$RUNNER_TEMP/t3code-preview.ipa" "$profile_path" > "$RUNNER_TEMP/preview.mobileprovision"
412 security cms -D -i "$RUNNER_TEMP/preview.mobileprovision" > "$RUNNER_TEMP/preview-profile.plist"
413 record="$(node .github/scripts/mobile-ios-preview-record.cjs create "$LINK" "$RUNNER_TEMP/preview-profile.plist")"
414 echo "record=$record" >> "$GITHUB_OUTPUT"
415
416 # Replaces an expired record for the same fingerprint.
417 - name: Record build
418 if: steps.record.outputs.built != 'true'
419 uses: ./.github/actions/record-build-tag
420 with:
421 tag: ${{ env.BUILD_TAG }}
422 message: ${{ steps.profile.outputs.record }}
423 replace: "true"
424 token: ${{ github.token }}
425
426 comment:
427 name: Mobile preview comment
428 needs: [android, ios, android-build, ios-build]
429 if: always() && !cancelled() && (needs.android.result == 'success' || needs.ios.result == 'success')
430 runs-on: blacksmith-2vcpu-ubuntu-2404
431 concurrency:
432 group: mobile-preview-comment-${{ github.event.pull_request.number }}
433 cancel-in-progress: false
434 permissions:
435 contents: read
436 pull-requests: write
437 steps:
438 - name: Checkout comment script
439 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
440 with:
441 sparse-checkout: .github/scripts
442
443 - name: Comment
444 env:
445 GH_TOKEN: ${{ github.token }}
446 PR: ${{ github.event.pull_request.number }}
447 PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
448 ANDROID_FINGERPRINT: ${{ needs.android.outputs.fingerprint }}
449 ANDROID_GROUP: ${{ needs.android.outputs.group }}
450 ANDROID_CLIENT: ${{ needs.android-build.outputs.client || needs.android.outputs.client }}
451 IOS_FINGERPRINT: ${{ needs.ios.outputs.fingerprint }}
452 IOS_GROUP: ${{ needs.ios.outputs.group }}
453 IOS_CLIENT: ${{ needs.ios-build.outputs.client || needs.ios.outputs.client }}
454 run: node .github/scripts/mobile-preview-comment.cjs