|
| 1 | +name: EAS local build |
| 2 | +description: Installs the toolchain and mobile dependencies, then runs `eas build --local` on this runner. |
| 3 | + |
| 4 | +inputs: |
| 5 | + platform: |
| 6 | + description: android or ios |
| 7 | + required: true |
| 8 | + profile: |
| 9 | + description: eas.json build profile |
| 10 | + required: true |
| 11 | + environment: |
| 12 | + description: EAS environment to pull, preview or production |
| 13 | + required: true |
| 14 | + expo-token: |
| 15 | + description: Expo token for that environment |
| 16 | + required: true |
| 17 | + output: |
| 18 | + description: Path the build artifact is written to |
| 19 | + required: true |
| 20 | + cache: |
| 21 | + description: "false for untrusted code: no sticky disk and no EAS cache, so nothing it writes reaches trusted builds" |
| 22 | + default: "true" |
| 23 | + sourcemaps-r2: |
| 24 | + description: R2 credentials for the eas-build-on-success source map upload; EAS secrets don't reach local builds |
| 25 | + default: "" |
| 26 | + |
| 27 | +runs: |
| 28 | + using: composite |
| 29 | + steps: |
| 30 | + - name: Prepare Android build cache |
| 31 | + if: inputs.platform == 'android' && inputs.cache == 'true' |
| 32 | + shell: bash |
| 33 | + env: |
| 34 | + CACHE_NAME: ${{ inputs.environment == 'production' && 'store' || 'preview' }} |
| 35 | + run: | |
| 36 | + cache="$HOME/.cache/t3-android-$CACHE_NAME" |
| 37 | + { |
| 38 | + echo "GRADLE_USER_HOME=$cache/gradle" |
| 39 | + echo "CCACHE_DIR=$cache/ccache" |
| 40 | + echo "CCACHE_MAXSIZE=5G" |
| 41 | + # Gradle installs the NDK fresh each run, so key on the compiler's version, not its mtime. |
| 42 | + echo "CCACHE_COMPILERCHECK=%compiler% -v" |
| 43 | + echo "pnpm_config_store_dir=$cache/pnpm-store" |
| 44 | + # eas build --local copies the project here. A fixed path keeps |
| 45 | + # ccache keys stable, and the same disk as the store lets pnpm hardlink. |
| 46 | + echo "EAS_LOCAL_BUILD_WORKINGDIR=$cache/eas-build" |
| 47 | + echo "CCACHE_BASEDIR=$cache/eas-build" |
| 48 | + # CMake (3.17+) reads these, and AGP passes Gradle's environment through. |
| 49 | + echo "CMAKE_C_COMPILER_LAUNCHER=ccache" |
| 50 | + echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" |
| 51 | + } >> "$GITHUB_ENV" |
| 52 | +
|
| 53 | + - name: Mount Android build cache |
| 54 | + if: inputs.platform == 'android' && inputs.cache == 'true' |
| 55 | + uses: useblacksmith/stickydisk@3f6be1451e3cad893b778bc93495c80452a5da26 # v1.7.2 |
| 56 | + with: |
| 57 | + key: ${{ github.repository }}-android-${{ inputs.environment == 'production' && 'store' || 'preview' }}-build |
| 58 | + path: ~/.cache/t3-android-${{ inputs.environment == 'production' && 'store' || 'preview' }} |
| 59 | + |
| 60 | + - name: Configure Gradle and ccache |
| 61 | + if: inputs.platform == 'android' && inputs.cache == 'true' |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + mkdir -p "$GRADLE_USER_HOME" "$CCACHE_DIR" |
| 65 | + rm -rf "$EAS_LOCAL_BUILD_WORKINGDIR" |
| 66 | + # No daemon: nothing should hold the sticky disk open when it is committed. |
| 67 | + printf 'org.gradle.caching=true\norg.gradle.daemon=false\n' > "$GRADLE_USER_HOME/gradle.properties" |
| 68 | + sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources |
| 69 | + sudo apt-get update -qq && sudo apt-get install -y -qq ccache |
| 70 | + ccache --zero-stats |
| 71 | +
|
| 72 | + # Matches the EAS build image in eas.json. |
| 73 | + - name: Select Xcode 27.1 |
| 74 | + if: inputs.platform == 'ios' |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + xcode=/Applications/Xcode_27.1.app |
| 78 | + if [ ! -d "$xcode" ]; then |
| 79 | + ls -d /Applications/Xcode*.app |
| 80 | + echo "::error::Xcode 27.1 is not on this runner." |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | + sudo xcode-select -s "$xcode/Contents/Developer" |
| 84 | + xcodebuild -version |
| 85 | + echo "- Xcode: \`$(basename "$xcode")\`" >> "$GITHUB_STEP_SUMMARY" |
| 86 | +
|
| 87 | + # EAS's credentials step fails to import the distribution certificate without it. |
| 88 | + - name: Install Apple WWDR G3 intermediate |
| 89 | + if: inputs.platform == 'ios' |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + curl -fsSL -o "$RUNNER_TEMP/AppleWWDRCAG3.cer" https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer |
| 93 | + sudo security add-certificates -k /Library/Keychains/System.keychain "$RUNNER_TEMP/AppleWWDRCAG3.cer" || true |
| 94 | + security find-certificate -c "Apple Worldwide Developer Relations" /Library/Keychains/System.keychain | grep labl |
| 95 | +
|
| 96 | + - name: Setup Node |
| 97 | + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 |
| 98 | + with: |
| 99 | + node-version-file: package.json |
| 100 | + |
| 101 | + - name: Enable corepack |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + npm install --global corepack@latest |
| 105 | + corepack enable |
| 106 | + pnpm --version |
| 107 | +
|
| 108 | + # EAS commands load app.config.ts, whose plugins must resolve. Keep install |
| 109 | + # scripts: some download native assets that the build's fingerprint check hashes. |
| 110 | + - name: Install mobile dependencies |
| 111 | + shell: bash |
| 112 | + run: pnpm install --frozen-lockfile --prefer-offline --filter=@t3tools/mobile... |
| 113 | + |
| 114 | + - name: Setup Java |
| 115 | + if: inputs.platform == 'android' |
| 116 | + uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0 |
| 117 | + with: |
| 118 | + distribution: temurin |
| 119 | + java-version: 17 |
| 120 | + |
| 121 | + - name: Setup EAS |
| 122 | + uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1 |
| 123 | + with: |
| 124 | + eas-version: latest |
| 125 | + eas-cache: ${{ inputs.cache }} |
| 126 | + token: ${{ inputs.expo-token }} |
| 127 | + # npm, not pnpm: this only installs eas-cli into the action's own |
| 128 | + # tool dir, and pnpm 11 hard-fails that install on dtrace-provider's |
| 129 | + # ignored build script (no allowBuilds config outside the repo). |
| 130 | + packager: npm |
| 131 | + |
| 132 | + - name: Build tools |
| 133 | + if: inputs.platform == 'ios' |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + command -v pod || sudo gem install cocoapods --no-document |
| 137 | + command -v fastlane || brew install fastlane |
| 138 | + pod --version |
| 139 | + fastlane --version | tail -1 |
| 140 | +
|
| 141 | + # EAS commands skip dotenv, and the Android fingerprint hashes this file. |
| 142 | + - name: Pull ${{ inputs.environment }} environment variables |
| 143 | + shell: bash |
| 144 | + working-directory: apps/mobile |
| 145 | + env: |
| 146 | + EXPO_TOKEN: ${{ inputs.expo-token }} |
| 147 | + ENVIRONMENT: ${{ inputs.environment }} |
| 148 | + PLATFORM: ${{ inputs.platform }} |
| 149 | + run: | |
| 150 | + eas env:pull "$ENVIRONMENT" --non-interactive |
| 151 | + node --input-type=module <<'NODE' |
| 152 | + import { appendFileSync, readFileSync } from "node:fs"; |
| 153 | + import { parseEnv } from "node:util"; |
| 154 | + const env = parseEnv(readFileSync(".env.local", "utf8")); |
| 155 | + const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE; |
| 156 | + if (!googleServicesFile && process.env.PLATFORM === "android") { |
| 157 | + throw new Error(`T3CODE_ANDROID_GOOGLE_SERVICES_FILE is missing from the ${process.env.ENVIRONMENT} environment`); |
| 158 | + } |
| 159 | + if (googleServicesFile) { |
| 160 | + appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`); |
| 161 | + } |
| 162 | + NODE |
| 163 | +
|
| 164 | + - name: Build |
| 165 | + shell: bash |
| 166 | + working-directory: apps/mobile |
| 167 | + env: |
| 168 | + EXPO_TOKEN: ${{ inputs.expo-token }} |
| 169 | + MOBILE_SOURCEMAPS_R2: ${{ inputs.sourcemaps-r2 }} |
| 170 | + PLATFORM: ${{ inputs.platform }} |
| 171 | + PROFILE: ${{ inputs.profile }} |
| 172 | + OUTPUT: ${{ inputs.output }} |
| 173 | + run: | |
| 174 | + if [ "$PLATFORM" = "ios" ]; then |
| 175 | + # A real path: /var -> /private/var symlinks break the expo-widgets bundle step. |
| 176 | + export EAS_LOCAL_BUILD_WORKINGDIR="$RUNNER_TEMP/eas-build" |
| 177 | + fi |
| 178 | + eas build --local --platform "$PLATFORM" --profile "$PROFILE" --non-interactive --output "$OUTPUT" |
| 179 | +
|
| 180 | + - name: Report ccache |
| 181 | + if: inputs.platform == 'android' && inputs.cache == 'true' |
| 182 | + shell: bash |
| 183 | + run: | |
| 184 | + { |
| 185 | + echo '```' |
| 186 | + ccache --show-stats |
| 187 | + echo '```' |
| 188 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments