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
| 1 | name: Mobile EAS Production |
| 2 | |
| 3 | # Production builds and OTA updates run from CI (Linux) — never from a laptop. |
| 4 | # Under the fingerprint runtime-version policy the fingerprint must be computed |
| 5 | # in the same OS/pnpm as the EAS build; a macOS `eas build` computes a different |
| 6 | # fingerprint (platform-specific deps + pnpm version) and errors. On this Linux |
| 7 | # runner, with corepack pinning pnpm 10.24 in eas.json, local == build. |
| 8 | # |
| 9 | # Every merge reconciles native fingerprints and publishes matching OTAs. |
| 10 | # Store builds run here with `eas build --local` on Blacksmith (the android and |
| 11 | # ios jobs). Local builds never appear in `eas build:list`, so each finished build |
| 12 | # pushes a mobile-android-build/<version>/<fingerprint> or |
| 13 | # mobile-ios-build/<profile>/<version>/<fingerprint> tag that the reconcile reads. |
| 14 | # iOS prereleases use the testflight profile (3.0.0); App Store binaries use |
| 15 | # production and the committed app version, built manually. Both receive OTAs |
| 16 | # for their own major version. Android continues using production automatically. |
| 17 | # TestFlight beta review may still be required for subsequent builds. |
| 18 | # Hold native-change PRs (the "📱 Native Change" label) and merge them as a |
| 19 | # batch to avoid a store build per PR. |
| 20 | # workflow_dispatch remains as a manual override for both modes (e.g. to |
| 21 | # retry an errored build or force an OTA). |
| 22 | on: |
| 23 | workflow_dispatch: |
| 24 | inputs: |
| 25 | mode: |
| 26 | description: "build (+ auto-submit to TestFlight / Google Play) or update (OTA)" |
| 27 | required: true |
| 28 | type: choice |
| 29 | default: build |
| 30 | options: |
| 31 | - build |
| 32 | - update |
| 33 | profile: |
| 34 | description: "production: store release; testflight: iOS 3.0.0 beta" |
| 35 | required: true |
| 36 | type: choice |
| 37 | default: production |
| 38 | options: |
| 39 | - production |
| 40 | - testflight |
| 41 | platform: |
| 42 | description: "Target platform" |
| 43 | required: true |
| 44 | type: choice |
| 45 | default: all |
| 46 | options: |
| 47 | - ios |
| 48 | - android |
| 49 | - all |
| 50 | version: |
| 51 | description: "Optional build version override (blank uses profile default; store overrides are committed)" |
| 52 | required: false |
| 53 | type: string |
| 54 | message: |
| 55 | description: "OTA update message (mode=update only)" |
| 56 | required: false |
| 57 | type: string |
| 58 | push: |
| 59 | branches: [main] |
| 60 | paths: |
| 61 | - apps/mobile/** |
| 62 | - packages/client-runtime/** |
| 63 | - packages/contracts/** |
| 64 | - packages/shared/** |
| 65 | - assets/** |
| 66 | - scripts/** |
| 67 | - patches/** |
| 68 | - pnpm-lock.yaml |
| 69 | - pnpm-workspace.yaml |
| 70 | - .github/workflows/mobile-eas-production.yml |
| 71 | |
| 72 | jobs: |
| 73 | production: |
| 74 | name: EAS ${{ inputs.profile || 'production' }} ${{ github.event_name == 'push' && 'auto' || inputs.mode }} |
| 75 | if: github.repository == 'pingdotgg/t3code' |
| 76 | runs-on: blacksmith-8vcpu-ubuntu-2404 |
| 77 | # Serialize runs so OTAs publish in merge order. GitHub keeps at most one |
| 78 | # queued job per group, so a burst of merges collapses into one run of the |
| 79 | # newest commit — intermediate commits don't need their own OTA. |
| 80 | concurrency: |
| 81 | group: mobile-eas-production |
| 82 | cancel-in-progress: false |
| 83 | permissions: |
| 84 | contents: read |
| 85 | outputs: |
| 86 | android_build: ${{ steps.reconcile.outputs.android_build || steps.android_manual.outputs.android_build }} |
| 87 | android_fingerprint: ${{ steps.reconcile.outputs.android_fingerprint || steps.android_manual.outputs.android_fingerprint }} |
| 88 | android_version: ${{ steps.reconcile.outputs.android_version || steps.android_manual.outputs.android_version }} |
| 89 | android_sha: ${{ steps.reconcile.outputs.android_sha || steps.android_manual.outputs.android_sha }} |
| 90 | ios_build: ${{ steps.reconcile.outputs.ios_build || steps.ios_manual.outputs.ios_build }} |
| 91 | ios_profile: ${{ steps.reconcile.outputs.ios_profile || steps.ios_manual.outputs.ios_profile }} |
| 92 | ios_fingerprint: ${{ steps.reconcile.outputs.ios_fingerprint || steps.ios_manual.outputs.ios_fingerprint }} |
| 93 | ios_version: ${{ steps.reconcile.outputs.ios_version || steps.ios_manual.outputs.ios_version }} |
| 94 | ios_sha: ${{ steps.reconcile.outputs.ios_sha || steps.ios_manual.outputs.ios_sha }} |
| 95 | env: |
| 96 | APP_VARIANT: production |
| 97 | NODE_OPTIONS: --max-old-space-size=8192 |
| 98 | steps: |
| 99 | - name: Validate TestFlight inputs |
| 100 | if: github.event_name == 'workflow_dispatch' && inputs.profile == 'testflight' |
| 101 | env: |
| 102 | PLATFORM: ${{ inputs.platform }} |
| 103 | VERSION: ${{ inputs.version }} |
| 104 | run: | |
| 105 | if [ "$PLATFORM" != "ios" ] || [ -n "$VERSION" ]; then |
| 106 | echo "::error::TestFlight uses platform=ios and its fixed version. Use production for a committed store version." |
| 107 | exit 1 |
| 108 | fi |
| 109 | |
| 110 | - id: expo-token |
| 111 | name: Check for EXPO_TOKEN |
| 112 | env: |
| 113 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 114 | run: | |
| 115 | if [ -n "$EXPO_TOKEN" ]; then |
| 116 | echo "present=true" >> "$GITHUB_OUTPUT" |
| 117 | else |
| 118 | echo "present=false" >> "$GITHUB_OUTPUT" |
| 119 | echo "EXPO_PRODUCTION_TOKEN is not available; skipping EAS production job." |
| 120 | fi |
| 121 | |
| 122 | - id: version_app_token |
| 123 | name: Mint release app token for version override |
| 124 | if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.version != '' && inputs.profile != 'testflight' |
| 125 | uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2 |
| 126 | with: |
| 127 | app-id: ${{ secrets.RELEASE_APP_ID }} |
| 128 | private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} |
| 129 | owner: ${{ github.repository_owner }} |
| 130 | |
| 131 | - name: Checkout |
| 132 | if: steps.expo-token.outputs.present == 'true' |
| 133 | uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 |
| 134 | with: |
| 135 | fetch-depth: 0 |
| 136 | token: ${{ steps.version_app_token.outputs.token || github.token }} |
| 137 | # No sparse-checkout here: it makes actions/checkout fetch with |
| 138 | # --filter=blob:none, and eas-cli archives the project via |
| 139 | # `git clone --depth 1 file://<workspace>`, which fails (exit 128) |
| 140 | # when the partial clone can't serve the unfetched blobs. |
| 141 | |
| 142 | - name: Setup Vite+ |
| 143 | if: steps.expo-token.outputs.present == 'true' |
| 144 | uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 |
| 145 | with: |
| 146 | node-version-file: package.json |
| 147 | cache: true |
| 148 | run-install: | |
| 149 | args: |
| 150 | - --filter=@t3tools/mobile... |
| 151 | |
| 152 | - name: Expose pnpm |
| 153 | if: steps.expo-token.outputs.present == 'true' |
| 154 | run: | |
| 155 | pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")" |
| 156 | vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin" |
| 157 | echo "$vp_pnpm_bin" >> "$GITHUB_PATH" |
| 158 | "$vp_pnpm_bin/pnpm" --version |
| 159 | |
| 160 | - name: Setup EAS |
| 161 | if: steps.expo-token.outputs.present == 'true' |
| 162 | uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1 |
| 163 | with: |
| 164 | eas-version: latest |
| 165 | token: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 166 | # npm, not pnpm: this only installs eas-cli into the action's own |
| 167 | # tool dir, and pnpm 11 hard-fails that install on dtrace-provider's |
| 168 | # ignored build script (no allowBuilds config outside the repo). |
| 169 | packager: npm |
| 170 | |
| 171 | - name: Pull production environment variables |
| 172 | if: steps.expo-token.outputs.present == 'true' |
| 173 | working-directory: apps/mobile |
| 174 | env: |
| 175 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 176 | run: | |
| 177 | eas env:pull production --non-interactive |
| 178 | # EAS commands skip dotenv, and the Android fingerprint hashes this |
| 179 | # file. Without it every merge misses the build's hash and rebuilds. |
| 180 | node --input-type=module <<'NODE' |
| 181 | import { appendFileSync, readFileSync } from "node:fs"; |
| 182 | import { parseEnv } from "node:util"; |
| 183 | const env = parseEnv(readFileSync(".env.local", "utf8")); |
| 184 | const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE; |
| 185 | if (!googleServicesFile) { |
| 186 | throw new Error("T3CODE_ANDROID_GOOGLE_SERVICES_FILE is missing from the production environment"); |
| 187 | } |
| 188 | appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`); |
| 189 | NODE |
| 190 | |
| 191 | - name: Apply manual version override |
| 192 | if: steps.version_app_token.outcome == 'success' |
| 193 | env: |
| 194 | GH_TOKEN: ${{ steps.version_app_token.outputs.token }} |
| 195 | APP_SLUG: ${{ steps.version_app_token.outputs.app-slug }} |
| 196 | RELEASE_VERSION: ${{ inputs.version }} |
| 197 | run: | |
| 198 | if [ "$GITHUB_REF_TYPE" != "branch" ]; then |
| 199 | echo "Version overrides require dispatching this workflow from a branch; received $GITHUB_REF_TYPE '$GITHUB_REF_NAME'." >&2 |
| 200 | exit 1 |
| 201 | fi |
| 202 | if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}$ ]]; then |
| 203 | echo "Version override must contain two or three dot-separated integers; received '$RELEASE_VERSION'." >&2 |
| 204 | exit 1 |
| 205 | fi |
| 206 | |
| 207 | node --input-type=module -e ' |
| 208 | import fs from "node:fs"; |
| 209 | const path = "apps/mobile/app.config.ts"; |
| 210 | const source = fs.readFileSync(path, "utf8"); |
| 211 | const next = source.replace( |
| 212 | /^( version: repoEnv\.T3CODE_MOBILE_VERSION \?\? ")[^"]+(".*)$/m, |
| 213 | `$1${process.env.RELEASE_VERSION}$2`, |
| 214 | ); |
| 215 | if (next === source && !source.includes(` version: repoEnv.T3CODE_MOBILE_VERSION ?? "${process.env.RELEASE_VERSION}"`)) { |
| 216 | throw new Error("Could not update app version"); |
| 217 | } |
| 218 | fs.writeFileSync(path, next); |
| 219 | ' |
| 220 | vp fmt apps/mobile/app.config.ts |
| 221 | |
| 222 | if git diff --quiet -- apps/mobile/app.config.ts; then |
| 223 | echo "app.config.ts is already at $RELEASE_VERSION; no version commit needed." |
| 224 | exit 0 |
| 225 | fi |
| 226 | |
| 227 | user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)" |
| 228 | git config user.name "${APP_SLUG}[bot]" |
| 229 | git config user.email "${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" |
| 230 | git add apps/mobile/app.config.ts |
| 231 | git commit --no-verify -m "chore(mobile): bump app version to $RELEASE_VERSION" |
| 232 | git push origin "HEAD:refs/heads/${GITHUB_REF_NAME}" |
| 233 | |
| 234 | - name: Summarize manual build version |
| 235 | if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' |
| 236 | working-directory: apps/mobile |
| 237 | env: |
| 238 | MOBILE_BUILD_PROFILE: ${{ inputs.profile || 'production' }} |
| 239 | run: | |
| 240 | if [ "$MOBILE_BUILD_PROFILE" = "testflight" ]; then |
| 241 | T3CODE_MOBILE_VERSION="$(node -p 'require("./eas.json").build.testflight.env.T3CODE_MOBILE_VERSION')" |
| 242 | export T3CODE_MOBILE_VERSION |
| 243 | fi |
| 244 | version="$(npx expo config --json --type public | jq -r '.version')" |
| 245 | { |
| 246 | echo "## Manual $MOBILE_BUILD_PROFILE build" |
| 247 | echo |
| 248 | echo "- App version: \`$version\`" |
| 249 | echo "- Platform: \`${{ inputs.platform }}\`" |
| 250 | echo |
| 251 | echo "> Apple closes an iOS release train after App Store approval. Before building iOS, confirm \`$version\` is newer than the approved App Store version." |
| 252 | } >> "$GITHUB_STEP_SUMMARY" |
| 253 | |
| 254 | - id: ios_manual |
| 255 | name: Queue iOS build (manual) |
| 256 | if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.platform != 'android' |
| 257 | working-directory: apps/mobile |
| 258 | env: |
| 259 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 260 | MOBILE_BUILD_PROFILE: ${{ inputs.profile || 'production' }} |
| 261 | run: | |
| 262 | if [ "$MOBILE_BUILD_PROFILE" = "testflight" ]; then |
| 263 | T3CODE_MOBILE_VERSION="$(node -p 'require("./eas.json").build.testflight.env.T3CODE_MOBILE_VERSION')" |
| 264 | export T3CODE_MOBILE_VERSION |
| 265 | fi |
| 266 | version="$(npx expo config --json --type public | jq -r '.version')" |
| 267 | hash="$(eas fingerprint:generate --platform ios --environment production --json --non-interactive | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')" |
| 268 | { |
| 269 | echo "ios_build=true" |
| 270 | echo "ios_profile=$MOBILE_BUILD_PROFILE" |
| 271 | echo "ios_fingerprint=$hash" |
| 272 | echo "ios_version=$version" |
| 273 | echo "ios_sha=$(git rev-parse HEAD)" |
| 274 | } >> "$GITHUB_OUTPUT" |
| 275 | |
| 276 | - id: android_manual |
| 277 | name: Queue Android build (manual) |
| 278 | if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.platform != 'ios' |
| 279 | working-directory: apps/mobile |
| 280 | env: |
| 281 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 282 | run: | |
| 283 | version="$(npx expo config --json --type public | jq -r '.version')" |
| 284 | hash="$(eas fingerprint:generate --platform android --environment production --json --non-interactive | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')" |
| 285 | { |
| 286 | echo "android_build=true" |
| 287 | echo "android_fingerprint=$hash" |
| 288 | echo "android_version=$version" |
| 289 | echo "android_sha=$(git rev-parse HEAD)" |
| 290 | } >> "$GITHUB_OUTPUT" |
| 291 | |
| 292 | # @expo/fingerprint swallows autolinking errors and returns no Expo module |
| 293 | # sources, so native changes stop moving the hash and OTAs reach binaries |
| 294 | # that lack them. Refuse to publish any OTA from such a fingerprint. |
| 295 | - name: Verify fingerprints hash Expo native modules |
| 296 | if: steps.expo-token.outputs.present == 'true' && (github.event_name == 'push' || inputs.mode == 'update') |
| 297 | working-directory: apps/mobile |
| 298 | env: |
| 299 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 300 | PLATFORM: ${{ inputs.platform || 'all' }} |
| 301 | run: | |
| 302 | if [ "$PLATFORM" = "all" ]; then platforms="ios android"; else platforms="$PLATFORM"; fi |
| 303 | failed=0 |
| 304 | for platform in $platforms; do |
| 305 | # eas-cli prints an environment-loaded notice to stdout before the |
| 306 | # JSON even with --json, so discard everything before the document. |
| 307 | expo_modules="$(eas fingerprint:generate --platform "$platform" --environment production --json --non-interactive | sed -n '/^{/,$p' | jq --arg reason "expoAutolinking${platform^}" '[.sources[] | select((.reasons // []) | index($reason))] | length')" |
| 308 | if [ "${expo_modules:-0}" -eq 0 ]; then |
| 309 | failed=1 |
| 310 | echo ":x: $platform: the native fingerprint hashes no Expo native modules — OTAs and builds skipped" >> "$GITHUB_STEP_SUMMARY" |
| 311 | fi |
| 312 | done |
| 313 | exit "$failed" |
| 314 | |
| 315 | - name: Publish OTA update (manual) |
| 316 | if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'update' |
| 317 | working-directory: apps/mobile |
| 318 | env: |
| 319 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 320 | MOBILE_BUILD_PROFILE: ${{ inputs.profile || 'production' }} |
| 321 | OTA_MESSAGE: ${{ inputs.message || format('Production OTA ({0})', github.sha) }} |
| 322 | run: | |
| 323 | if [ "$MOBILE_BUILD_PROFILE" = "testflight" ]; then |
| 324 | T3CODE_MOBILE_VERSION="$(node -p 'require("./eas.json").build.testflight.env.T3CODE_MOBILE_VERSION')" |
| 325 | export T3CODE_MOBILE_VERSION |
| 326 | fi |
| 327 | eas update \ |
| 328 | --channel production \ |
| 329 | --environment production \ |
| 330 | --platform ${{ inputs.platform }} \ |
| 331 | --message "$OTA_MESSAGE" \ |
| 332 | --emit-metadata \ |
| 333 | --non-interactive |
| 334 | |
| 335 | # Reconcile each version separately because the major is in the fingerprint. |
| 336 | # Production iOS only receives OTAs here; store binaries are manual releases. |
| 337 | # Failed prerelease builds are retried manually, not on every merge. |
| 338 | - id: reconcile |
| 339 | name: Publish OTA or cut store build |
| 340 | if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push' |
| 341 | working-directory: apps/mobile |
| 342 | env: |
| 343 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 344 | run: | |
| 345 | failed=0 |
| 346 | message="$(git log -1 --pretty=%s | head -c 120) ($(git rev-parse --short=9 HEAD))" |
| 347 | for target in ios:production ios:testflight android:production; do |
| 348 | platform="${target%%:*}" |
| 349 | profile="${target#*:}" |
| 350 | unset T3CODE_MOBILE_VERSION |
| 351 | if [ "$profile" = "testflight" ]; then |
| 352 | T3CODE_MOBILE_VERSION="$(node -p 'require("./eas.json").build.testflight.env.T3CODE_MOBILE_VERSION')" |
| 353 | export T3CODE_MOBILE_VERSION |
| 354 | fi |
| 355 | version="$(npx expo config --json --type public | jq -r '.version')" |
| 356 | # eas-cli prints an environment-loaded notice to stdout before the |
| 357 | # JSON even with --json, so discard everything before the document. |
| 358 | hash="$(eas fingerprint:generate --platform "$platform" --environment production --json --non-interactive | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')" |
| 359 | matches="$(eas build:list --platform "$platform" --build-profile "$profile" --fingerprint-hash "$hash" --limit 20 --json --non-interactive)" |
| 360 | finished="$(jq '[.[] | select(.status == "FINISHED")] | length' <<<"$matches")" |
| 361 | active="$(jq '[.[] | select(.status == "NEW" or .status == "IN_QUEUE" or .status == "IN_PROGRESS")] | length' <<<"$matches")" |
| 362 | errored="$(jq '[.[] | select(.status == "ERRORED")] | length' <<<"$matches")" |
| 363 | latest_version="$(eas build:list --platform "$platform" --build-profile "$profile" --limit 1 --json --non-interactive | jq -r '.[0].appVersion // "none"')" |
| 364 | # Local builds (the android and ios jobs) record each build as a tag; |
| 365 | # EAS records still count for builds made before that. |
| 366 | if [ "$platform" = "android" ]; then |
| 367 | tag_prefix="mobile-android-build" |
| 368 | else |
| 369 | tag_prefix="mobile-ios-build/$profile" |
| 370 | fi |
| 371 | if [ -n "$(git tag -l "$tag_prefix/*/$hash")" ]; then |
| 372 | finished=$((finished + 1)) |
| 373 | fi |
| 374 | if [ -n "$(git tag -l "$tag_prefix/$version/*")" ]; then |
| 375 | latest_version="$version" |
| 376 | fi |
| 377 | |
| 378 | if [ "$finished" -gt 0 ]; then |
| 379 | if eas update \ |
| 380 | --channel production \ |
| 381 | --environment production \ |
| 382 | --platform "$platform" \ |
| 383 | --message "$message" \ |
| 384 | --emit-metadata \ |
| 385 | --non-interactive; then |
| 386 | echo ":white_check_mark: $platform/$profile: OTA published to production (fingerprint \`$hash\`)" >> "$GITHUB_STEP_SUMMARY" |
| 387 | # The next target's export replaces dist; keep this one for the map upload. |
| 388 | rm -rf "dist-$platform-$profile" && mv dist "dist-$platform-$profile" |
| 389 | else |
| 390 | failed=1 |
| 391 | echo ":x: $platform/$profile: OTA publish failed (fingerprint \`$hash\`)" >> "$GITHUB_STEP_SUMMARY" |
| 392 | fi |
| 393 | fi |
| 394 | |
| 395 | # Never rebuild the released iOS version automatically. |
| 396 | if [ "$target" = "ios:production" ]; then |
| 397 | continue |
| 398 | fi |
| 399 | |
| 400 | reason="" |
| 401 | if [ "$finished" -eq 0 ] && [ "$active" -eq 0 ]; then |
| 402 | if [ "$errored" -gt 0 ]; then |
| 403 | echo ":x: $platform/$profile: the build for fingerprint \`$hash\` errored — retry with workflow_dispatch mode=build profile=$profile platform=$platform" >> "$GITHUB_STEP_SUMMARY" |
| 404 | failed=1 |
| 405 | continue |
| 406 | fi |
| 407 | reason="native fingerprint \`$hash\` has no build" |
| 408 | elif [ "$latest_version" != "$version" ] && [ "$active" -eq 0 ]; then |
| 409 | reason="latest $profile build is $latest_version, expected $version" |
| 410 | fi |
| 411 | |
| 412 | if [ -z "$reason" ]; then |
| 413 | if [ "$finished" -eq 0 ]; then |
| 414 | echo ":hourglass: $platform/$profile: build for fingerprint \`$hash\` is in progress — OTA resumes on the next merge after it finishes" >> "$GITHUB_STEP_SUMMARY" |
| 415 | fi |
| 416 | continue |
| 417 | fi |
| 418 | |
| 419 | echo "$platform: $reason — building" |
| 420 | if [ "$platform" = "android" ]; then |
| 421 | { |
| 422 | echo "android_build=true" |
| 423 | echo "android_fingerprint=$hash" |
| 424 | echo "android_version=$version" |
| 425 | echo "android_sha=$(git rev-parse HEAD)" |
| 426 | } >> "$GITHUB_OUTPUT" |
| 427 | echo ":building_construction: android: building and submitting $version in the Android store build job ($reason)" >> "$GITHUB_STEP_SUMMARY" |
| 428 | continue |
| 429 | fi |
| 430 | { |
| 431 | echo "ios_build=true" |
| 432 | echo "ios_profile=$profile" |
| 433 | echo "ios_fingerprint=$hash" |
| 434 | echo "ios_version=$version" |
| 435 | echo "ios_sha=$(git rev-parse HEAD)" |
| 436 | } >> "$GITHUB_OUTPUT" |
| 437 | echo ":building_construction: ios/$profile: building and submitting $version in the iOS store build job ($reason)" >> "$GITHUB_STEP_SUMMARY" |
| 438 | done |
| 439 | exit "$failed" |
| 440 | |
| 441 | # Lets the relay symbolicate crash stacks from the updates published |
| 442 | # above. A step of its own so the R2 credentials reach only this script, |
| 443 | # not `eas update` and the dependencies it runs. Never fails the job. |
| 444 | - name: Upload OTA source maps |
| 445 | if: ${{ !cancelled() && steps.expo-token.outputs.present == 'true' }} |
| 446 | working-directory: apps/mobile |
| 447 | env: |
| 448 | MOBILE_SOURCEMAPS_R2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }} |
| 449 | run: | |
| 450 | for dir in dist dist-*; do |
| 451 | if [ -f "$dir/eas-update-metadata.json" ]; then |
| 452 | node scripts/upload-sourcemaps.mts ota "$dir" |
| 453 | fi |
| 454 | done |
| 455 | |
| 456 | # ARM-only, without release lint (see the production profile in eas.json), |
| 457 | # with Gradle, ccache, and pnpm state on a sticky disk. Its own concurrency |
| 458 | # group keeps later OTAs from waiting on it. |
| 459 | android: |
| 460 | name: Android store build |
| 461 | needs: production |
| 462 | # Skipped when the production job failed: no store build after a failed OTA. |
| 463 | if: needs.production.outputs.android_build == 'true' |
| 464 | runs-on: blacksmith-32vcpu-ubuntu-2404 |
| 465 | timeout-minutes: 60 |
| 466 | concurrency: |
| 467 | group: mobile-android-store-build |
| 468 | cancel-in-progress: false |
| 469 | permissions: |
| 470 | contents: write # pushes the build record tag |
| 471 | env: |
| 472 | APP_VARIANT: production |
| 473 | NODE_OPTIONS: --max-old-space-size=8192 |
| 474 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 475 | BUILD_TAG: mobile-android-build/${{ needs.production.outputs.android_version }}/${{ needs.production.outputs.android_fingerprint }} |
| 476 | steps: |
| 477 | - name: Checkout |
| 478 | uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 |
| 479 | with: |
| 480 | ref: ${{ needs.production.outputs.android_sha }} |
| 481 | fetch-depth: 0 |
| 482 | |
| 483 | # The steps below run dependency and build scripts; they get no token. |
| 484 | - name: Drop checkout credentials |
| 485 | uses: ./.github/actions/drop-checkout-credentials |
| 486 | |
| 487 | # A queued run can follow a build of the same fingerprint; manual runs always build. |
| 488 | - id: record |
| 489 | name: Check build record |
| 490 | env: |
| 491 | FORCE: ${{ github.event_name == 'workflow_dispatch' }} |
| 492 | run: | |
| 493 | if [ "$FORCE" != "true" ] && [ -n "$(git tag -l "$BUILD_TAG")" ]; then |
| 494 | echo "built=true" >> "$GITHUB_OUTPUT" |
| 495 | echo ":white_check_mark: android: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY" |
| 496 | fi |
| 497 | |
| 498 | - name: Build |
| 499 | if: steps.record.outputs.built != 'true' |
| 500 | uses: ./.github/actions/eas-local-build |
| 501 | with: |
| 502 | platform: android |
| 503 | profile: production |
| 504 | environment: production |
| 505 | expo-token: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 506 | output: ${{ runner.temp }}/t3code.aab |
| 507 | sourcemaps-r2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }} |
| 508 | |
| 509 | - name: Check ABIs |
| 510 | if: steps.record.outputs.built != 'true' |
| 511 | run: | |
| 512 | abis="$(unzip -Z1 "$RUNNER_TEMP/t3code.aab" | sed -n 's|^base/lib/\([^/]*\)/.*|\1|p' | sort -u | paste -sd, -)" |
| 513 | echo "### Android $BUILD_TAG: \`$abis\`" >> "$GITHUB_STEP_SUMMARY" |
| 514 | if [ "$abis" != "arm64-v8a,armeabi-v7a" ]; then |
| 515 | echo "::error::Expected only ARM native libraries in the AAB, found $abis" |
| 516 | exit 1 |
| 517 | fi |
| 518 | |
| 519 | # A --path submission doesn't keep its archive on EAS; this is the only downloadable copy. |
| 520 | - name: Keep the AAB |
| 521 | if: steps.record.outputs.built != 'true' |
| 522 | uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 523 | with: |
| 524 | name: android-store-aab-${{ github.run_id }}-${{ github.run_attempt }} |
| 525 | path: ${{ runner.temp }}/t3code.aab |
| 526 | retention-days: 14 |
| 527 | if-no-files-found: error |
| 528 | |
| 529 | - name: Submit to Google Play |
| 530 | if: steps.record.outputs.built != 'true' |
| 531 | working-directory: apps/mobile |
| 532 | run: eas submit --platform android --profile production --path "$RUNNER_TEMP/t3code.aab" --non-interactive |
| 533 | |
| 534 | # The tag means "delivered", so it follows the submit. If it can't be |
| 535 | # pushed, the next merge rebuilds with a new build number; nothing is lost. |
| 536 | - name: Record build |
| 537 | if: steps.record.outputs.built != 'true' |
| 538 | uses: ./.github/actions/record-build-tag |
| 539 | with: |
| 540 | tag: ${{ env.BUILD_TAG }} |
| 541 | token: ${{ github.token }} |
| 542 | |
| 543 | - name: Summarize |
| 544 | if: steps.record.outputs.built != 'true' |
| 545 | run: | |
| 546 | echo ":rocket: android: submitted and recorded \`$BUILD_TAG\`" >> "$GITHUB_STEP_SUMMARY" |
| 547 | |
| 548 | # No sticky disk: it mounts ext4 and only works on Linux runners. |
| 549 | ios: |
| 550 | name: iOS store build |
| 551 | needs: production |
| 552 | # Skipped when the production job failed: no store build after a failed OTA. |
| 553 | if: needs.production.outputs.ios_build == 'true' |
| 554 | runs-on: blacksmith-12vcpu-macos-27 |
| 555 | timeout-minutes: 60 |
| 556 | concurrency: |
| 557 | group: mobile-ios-store-build |
| 558 | cancel-in-progress: false |
| 559 | permissions: |
| 560 | contents: write # pushes the build record tag |
| 561 | env: |
| 562 | APP_VARIANT: production |
| 563 | NODE_OPTIONS: --max-old-space-size=8192 |
| 564 | EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 565 | PROFILE: ${{ needs.production.outputs.ios_profile }} |
| 566 | BUILD_TAG: mobile-ios-build/${{ needs.production.outputs.ios_profile }}/${{ needs.production.outputs.ios_version }}/${{ needs.production.outputs.ios_fingerprint }} |
| 567 | steps: |
| 568 | - name: Checkout |
| 569 | uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 |
| 570 | with: |
| 571 | ref: ${{ needs.production.outputs.ios_sha }} |
| 572 | fetch-depth: 0 |
| 573 | |
| 574 | # The steps below run dependency and build scripts; they get no token. |
| 575 | - name: Drop checkout credentials |
| 576 | uses: ./.github/actions/drop-checkout-credentials |
| 577 | |
| 578 | # A queued run can follow a build of the same fingerprint; manual runs always build. |
| 579 | - id: record |
| 580 | name: Check build record |
| 581 | env: |
| 582 | FORCE: ${{ github.event_name == 'workflow_dispatch' }} |
| 583 | run: | |
| 584 | if [ "$FORCE" != "true" ] && [ -n "$(git tag -l "$BUILD_TAG")" ]; then |
| 585 | echo "built=true" >> "$GITHUB_OUTPUT" |
| 586 | echo ":white_check_mark: ios: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY" |
| 587 | fi |
| 588 | |
| 589 | - name: Build |
| 590 | if: steps.record.outputs.built != 'true' |
| 591 | uses: ./.github/actions/eas-local-build |
| 592 | with: |
| 593 | platform: ios |
| 594 | profile: ${{ env.PROFILE }} |
| 595 | environment: production |
| 596 | expo-token: ${{ secrets.EXPO_PRODUCTION_TOKEN }} |
| 597 | output: ${{ runner.temp }}/t3code.ipa |
| 598 | sourcemaps-r2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }} |
| 599 | |
| 600 | - name: Submit to App Store Connect |
| 601 | if: steps.record.outputs.built != 'true' |
| 602 | working-directory: apps/mobile |
| 603 | run: eas submit --platform ios --profile "$PROFILE" --path "$RUNNER_TEMP/t3code.ipa" --non-interactive |
| 604 | |
| 605 | # The tag means "delivered", so it follows the submit. If it can't be |
| 606 | # pushed, the next merge rebuilds with a new build number; nothing is lost. |
| 607 | - name: Record build |
| 608 | if: steps.record.outputs.built != 'true' |
| 609 | uses: ./.github/actions/record-build-tag |
| 610 | with: |
| 611 | tag: ${{ env.BUILD_TAG }} |
| 612 | token: ${{ github.token }} |
| 613 | |
| 614 | - name: Summarize |
| 615 | if: steps.record.outputs.built != 'true' |
| 616 | run: | |
| 617 | echo ":rocket: ios: submitted and recorded \`$BUILD_TAG\`" >> "$GITHUB_STEP_SUMMARY" |