Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/fork-manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ apps/mobile/src/features/threads/ThreadHeader.tsx icon: filesVisible ? "folder.f
.github/workflows/release-mobile-ios.yml key: ios-cas-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode.outputs.build }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'patches/**') }}
.github/workflows/release-mobile-ios.yml name: Bound the compilation cache
.github/workflows/release-mobile-ios.yml pnpm-store-cache: "false"
.github/workflows/release-mobile-ios.yml name: Refresh the JavaScript in the native app
.github/workflows/release-mobile-ios.yml echo "key=ios-native-app-v2-$hash-
.github/workflows/release-mobile-ios.yml hermesc/linux64-bin/hermesc

# Fork: Hosted macOS release jobs install from the registry instead of unpacking the slow cached pnpm store.
.github/actions/setup-ci-deps/action.yml Fork:
Expand Down
189 changes: 159 additions & 30 deletions .github/workflows/release-mobile-ios.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fork: Keep unsigned Personal Team IPA packaging, fork OTA isolation, iOS 17 checks, concurrency, and hosted compilation/dependency caches.
# Fork: Keep unsigned Personal Team IPA packaging, fork OTA isolation, iOS 17 checks, concurrency, hosted compilation/dependency caches, and native app reuse keyed by the Expo fingerprint.
# Fork-only: builds the mobile app as an unsigned iOS IPA for sideloading. Users re-sign it with
# their own Apple ID (AltStore, SideStore, Sideloadly), so it is the Personal Team build: no push,
# widget or share extension, or native Sign in with Apple. release.yml calls this when the fork
Expand Down Expand Up @@ -38,11 +38,87 @@ on:
type: string
default: 0.0.0-check

env:
RELEASE_VERSION: ${{ inputs.version || '0.0.0-check' }}
APP_VARIANT: production
T3CODE_IOS_PERSONAL_TEAM: "1"
T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID: ${{ vars.T3CODE_IOS_SIDELOAD_BUNDLE_ID || format('io.github.{0}.t3code', github.repository_owner) }}
# Upstream's Expo update channel must never replace the fork's JavaScript.
T3CODE_MOBILE_UPDATES_ENABLED: "0"
EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ inputs.clerk_publishable_key || vars.CLERK_PUBLISHABLE_KEY }}
EXPO_PUBLIC_CLERK_JWT_TEMPLATE: ${{ inputs.clerk_jwt_template || vars.CLERK_JWT_TEMPLATE }}
T3CODE_RELAY_URL: ${{ inputs.relay_url || (vars.RELAY_DOMAIN && format('https://{0}', vars.RELAY_DOMAIN)) || '' }}
EXPO_NO_GIT_STATUS: "1"
CI: "1"
COCOAPODS_DISABLE_STATS: "1"
# The saved native app. Restore and save must name the same path for the cache to match.
NATIVE_APP_PATH: apps/mobile/build/Build/Products/Release-iphoneos/*.app

defaults:
run:
working-directory: apps/mobile

# Most releases change only JavaScript. Expo's native fingerprint (the runtime version
# expo-updates embeds) keys the last native build: `native` runs xcodebuild on macOS only when no
# app is saved for it, and `ipa` always refreshes that app's JavaScript and packages it on Linux.
jobs:
ipa:
name: iOS unsigned IPA
fingerprint:
name: iOS native fingerprint
# A PR check only runs while macOS CI is on (T3CODE_MACOS_CI); releases always build.
if: vars.T3CODE_MOBILE_RELEASE == 'true' && (github.event_name != 'pull_request' || vars.T3CODE_MACOS_CI != 'false')
runs-on: ${{ vars.T3CODE_LINUX_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 15
outputs:
app_version: ${{ steps.version.outputs.app_version }}
key: ${{ steps.native.outputs.key }}
saved: ${{ steps.lookup.outputs.cache-hit }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.sha }}
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false

- name: Setup dependencies
uses: ./.github/actions/setup-ci-deps
with:
install-args: --filter=@t3tools/mobile...

# iOS accepts only up to three dot-separated integers, so drop any prerelease suffix.
- name: Resolve the app version
id: version
run: |
app_version="${RELEASE_VERSION%%-*}"
[[ "$app_version" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]] \
|| { echo "::error::cannot derive an iOS version from $RELEASE_VERSION"; exit 1; }
echo "T3CODE_MOBILE_VERSION=$app_version" >> "$GITHUB_ENV"
echo "app_version=$app_version" >> "$GITHUB_OUTPUT"

# The key also names this workflow, whose build settings shape the binary.
- name: Compute the native fingerprint
id: native
run: |
hash=$(node -e "require('expo/fingerprint').createFingerprintAsync(process.cwd(), { platforms: ['ios'], silent: true }).then(f => console.log(f.hash))")
[ -n "$hash" ] || { echo "::error::Expo returned no native fingerprint"; exit 1; }
echo "native fingerprint: $hash"
echo "key=ios-native-app-v2-$hash-${{ hashFiles('.github/workflows/release-mobile-ios.yml') }}" >> "$GITHUB_OUTPUT"

- name: Look up the native app
id: lookup
uses: actions/cache/restore@v6
with:
path: ${{ env.NATIVE_APP_PATH }}
key: ${{ steps.native.outputs.key }}
lookup-only: true
enableCrossOsArchive: true

native:
name: iOS native app
needs: fingerprint
if: needs.fingerprint.outputs.saved != 'true'
# One build per PR or branch. A new PR push cancels the stale build so it frees a scarce macOS
# runner; a release build waits instead of being cancelled.
concurrency:
Expand All @@ -51,21 +127,7 @@ jobs:
runs-on: ${{ vars.T3CODE_IOS_RUNNER || vars.T3CODE_MACOS_RUNNER || 'macos-26' }}
timeout-minutes: 120
env:
RELEASE_VERSION: ${{ inputs.version || '0.0.0-check' }}
APP_VARIANT: production
T3CODE_IOS_PERSONAL_TEAM: "1"
T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID: ${{ vars.T3CODE_IOS_SIDELOAD_BUNDLE_ID || format('io.github.{0}.t3code', github.repository_owner) }}
# Upstream's Expo update channel must never replace the fork's JavaScript.
T3CODE_MOBILE_UPDATES_ENABLED: "0"
EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ inputs.clerk_publishable_key || vars.CLERK_PUBLISHABLE_KEY }}
EXPO_PUBLIC_CLERK_JWT_TEMPLATE: ${{ inputs.clerk_jwt_template || vars.CLERK_JWT_TEMPLATE }}
T3CODE_RELAY_URL: ${{ inputs.relay_url || (vars.RELAY_DOMAIN && format('https://{0}', vars.RELAY_DOMAIN)) || '' }}
EXPO_NO_GIT_STATUS: "1"
CI: "1"
COCOAPODS_DISABLE_STATS: "1"
defaults:
run:
working-directory: apps/mobile
T3CODE_MOBILE_VERSION: ${{ needs.fingerprint.outputs.app_version }}
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -83,14 +145,6 @@ jobs:
# Restoring the cached store took ~5 minutes on hosted macOS; installing takes under one.
pnpm-store-cache: "false"

# iOS accepts only up to three dot-separated integers, so drop any prerelease suffix.
- name: Resolve the app version
run: |
app_version="${RELEASE_VERSION%%-*}"
[[ "$app_version" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]] \
|| { echo "::error::cannot derive an iOS version from $RELEASE_VERSION"; exit 1; }
echo "T3CODE_MOBILE_VERSION=$app_version" >> "$GITHUB_ENV"

- name: Resolve Xcode cache identity
id: xcode
run: |
Expand Down Expand Up @@ -173,13 +227,88 @@ jobs:
- name: Check the app runs on iOS 17
run: ../../.github/scripts/check-ios17-libcxx-imports.sh "$APP_PATH"

# Saved only after the iOS 17 check, so a reused native app has passed it.
- name: Save the native app
uses: actions/cache/save@v6
with:
path: ${{ env.NATIVE_APP_PATH }}
key: ${{ needs.fingerprint.outputs.key }}
enableCrossOsArchive: true

ipa:
name: iOS unsigned IPA
needs: [fingerprint, native]
if: ${{ !cancelled() && needs.fingerprint.result == 'success' && (needs.native.result == 'success' || needs.native.result == 'skipped') }}
runs-on: ${{ vars.T3CODE_LINUX_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 20
env:
T3CODE_MOBILE_VERSION: ${{ needs.fingerprint.outputs.app_version }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.sha }}
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false

- name: Setup dependencies
uses: ./.github/actions/setup-ci-deps
with:
install-args: --filter=@t3tools/mobile...

- name: Restore the native app
uses: actions/cache/restore@v6
with:
path: ${{ env.NATIVE_APP_PATH }}
key: ${{ needs.fingerprint.outputs.key }}
enableCrossOsArchive: true
fail-on-cache-miss: true

# Mirrors the app target's bundle phase (react-native-xcode.sh with expo export:embed and
# hermesc), its Info.plist version, and expo-constants' app.config phase, at Xcode's paths.
# Run on macOS this matched an xcodebuild app byte for byte; Linux hermesc lays out the same
# bytecode differently. Updates are disabled, so expo-updates never reads app.manifest.
- name: Refresh the JavaScript in the native app
env:
NODE_ENV: production
run: |
set -euo pipefail
products="$PWD/build/Build/Products/Release-iphoneos"
app=$(find "$products" -maxdepth 1 -name '*.app' | head -1)
[ -n "$app" ] || { echo "::error::the saved native app is missing"; exit 1; }
rm -rf "$app/assets" "$app/main.jsbundle"
vp exec expo export:embed --entry-file "$PWD/index.ts" --platform ios --dev false --reset-cache \
--bundle-output "$products/main.jsbundle" --assets-dest "$app" --minify false
hermes=$(dirname "$(node -p "require.resolve('hermes-compiler/package.json', { paths: [require('path').dirname(require.resolve('react-native/package.json'))] })")")
"$hermes/hermesc/linux64-bin/hermesc" -emit-binary -max-diagnostic-width=80 -O \
-out "$app/main.jsbundle" "$products/main.jsbundle" 2> "$RUNNER_TEMP/hermesc.log" \
|| { cat "$RUNNER_TEMP/hermesc.log"; exit 1; }
python3 - "$app/Info.plist" <<'EOF'
import os, plistlib, sys
path = sys.argv[1]
with open(path, "rb") as f:
info = plistlib.load(f)
version = os.environ["T3CODE_MOBILE_VERSION"]
if info["CFBundleShortVersionString"] != version:
info["CFBundleShortVersionString"] = version
with open(path, "wb") as f:
plistlib.dump(info, f)
EOF
node node_modules/expo-constants/scripts/getAppConfig.js "$PWD" "$app/EXConstants.bundle" ios false production
echo "APP_PATH=$app" >> "$GITHUB_ENV"

- name: Package the IPA
run: |
set -euo pipefail
plist="$APP_PATH/Info.plist"
min_os=$(/usr/libexec/PlistBuddy -c 'Print MinimumOSVersion' "$plist")
short_version=$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$plist")
bundle_id=$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$plist")
read -r min_os short_version bundle_id < <(python3 - "$APP_PATH/Info.plist" <<'EOF'
import plistlib, sys
with open(sys.argv[1], "rb") as f:
info = plistlib.load(f)
print(info["MinimumOSVersion"], info["CFBundleShortVersionString"], info["CFBundleIdentifier"])
EOF
)
echo "bundle $bundle_id, version $short_version, minimum iOS $min_os"
[ "$min_os" = "17.0" ] || { echo "::error::MinimumOSVersion is $min_os, expected 17.0"; exit 1; }
[ "$short_version" = "$T3CODE_MOBILE_VERSION" ] \
Expand Down
8 changes: 8 additions & 0 deletions docs/operations/fork-releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ the repository's 10 GB cache and evicted itself, turning ~13-minute builds into
ones. A restored cache over 8 GB on disk (a cold build makes about 4.2 GB) is dropped so it cannot crowd out the other caches. The macOS release jobs install packages from the registry instead of the cached pnpm store, which took 2.5 to 5 minutes to unpack on hosted macOS against about 30 seconds to install.
The `mobile-ios-build-log` artifact includes compilation-cache diagnostics and Xcode task timings.

Most releases need no macOS runner. A Linux job computes Expo's native fingerprint, the runtime
version expo-updates embeds, and looks for the native app saved for that fingerprint and workflow.
The macOS job runs xcodebuild only when none is saved. A Linux job then restores the app and
regenerates `main.jsbundle` (Metro and hermesc), its assets, the Info.plist version, and the
embedded Expo config, the outputs of Xcode's script phases. On macOS this matched an xcodebuild
app byte for byte; Linux hermesc emits equivalent bytecode with a different layout. A native change
or an edit to the workflow builds and saves a new native app; an Xcode update alone does not.

## Releases

Set `T3CODE_RELEASES` to `true`. The release workflow then builds nightlies on its schedule and
Expand Down
Loading