Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

mobile-eas-production-build.yml

199 lines7.1 KB

1name: Mobile EAS Production Build
2​
3# One store build and its build record, called per platform by
4# mobile-eas-production.yml. The build job runs dependency and build scripts with
5# a 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 queued run 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 profile:
17 description: eas.json build and submit profile
18 required: true
19 type: string
20 sha:
21 description: Commit to build and tag
22 required: true
23 type: string
24 tag:
25 description: Build record tag, without refs/tags/
26 required: true
27 type: string
28 secrets:
29 EXPO_PRODUCTION_TOKEN:
30 required: true
31 MOBILE_SOURCEMAPS_R2:
32 required: false
33​
34permissions:
35 contents: read
36​
37jobs:
38 # ARM-only, without release lint (see the production profile in eas.json),
39 # with Gradle, ccache, and pnpm state on a sticky disk.
40 android:
41 name: Build
42 if: ${{ !cancelled() && inputs.platform == 'android' }}
43 runs-on: blacksmith-32vcpu-ubuntu-2404
44 timeout-minutes: 60
45 permissions:
46 contents: read
47 outputs:
48 submitted: ${{ steps.submit.outcome == 'success' }}
49 env:
50 APP_VARIANT: production
51 NODE_OPTIONS: --max-old-space-size=8192
52 EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
53 BUILD_TAG: ${{ inputs.tag }}
54 steps:
55 - name: Checkout
56 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
57 with:
58 ref: ${{ inputs.sha }}
59 fetch-depth: 0
60​
61 # The steps below run dependency and build scripts; they get no token.
62 - name: Drop checkout credentials
63 uses: ./.github/actions/drop-checkout-credentials
64​
65 # A queued run can follow a build of the same fingerprint; manual runs always build.
66 - id: record
67 name: Check build record
68 env:
69 FORCE: ${{ github.event_name == 'workflow_dispatch' }}
70 run: |
71 if [ "$FORCE" != "true" ] && [ -n "$(git tag -l "$BUILD_TAG")" ]; then
72 echo "built=true" >> "$GITHUB_OUTPUT"
73 echo ":white_check_mark: android: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY"
74 fi
75​
76 - name: Build
77 if: steps.record.outputs.built != 'true'
78 uses: ./.github/actions/eas-local-build
79 with:
80 platform: android
81 profile: production
82 environment: production
83 expo-token: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
84 output: ${{ runner.temp }}/t3code.aab
85 sourcemaps-r2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }}
86​
87 - name: Check ABIs
88 if: steps.record.outputs.built != 'true'
89 run: |
90 abis="$(unzip -Z1 "$RUNNER_TEMP/t3code.aab" | sed -n 's|^base/lib/\([^/]*\)/.*|\1|p' | sort -u | paste -sd, -)"
91 echo "### Android $BUILD_TAG: \`$abis\`" >> "$GITHUB_STEP_SUMMARY"
92 if [ "$abis" != "arm64-v8a,armeabi-v7a" ]; then
93 echo "::error::Expected only ARM native libraries in the AAB, found $abis"
94 exit 1
95 fi
96​
97 # A --path submission doesn't keep its archive on EAS; this is the only downloadable copy.
98 - name: Keep the AAB
99 if: steps.record.outputs.built != 'true'
100 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
101 with:
102 name: android-store-aab-${{ github.run_id }}-${{ github.run_attempt }}
103 path: ${{ runner.temp }}/t3code.aab
104 retention-days: 14
105 if-no-files-found: error
106​
107 - id: submit
108 name: Submit to Google Play
109 if: steps.record.outputs.built != 'true'
110 working-directory: apps/mobile
111 run: eas submit --platform android --profile production --path "$RUNNER_TEMP/t3code.aab" --non-interactive
112​
113 # No sticky disk: it mounts ext4 and only works on Linux runners.
114 ios:
115 name: Build
116 if: ${{ !cancelled() && inputs.platform == 'ios' }}
117 runs-on: blacksmith-12vcpu-macos-27
118 timeout-minutes: 60
119 permissions:
120 contents: read
121 outputs:
122 submitted: ${{ steps.submit.outcome == 'success' }}
123 env:
124 APP_VARIANT: production
125 NODE_OPTIONS: --max-old-space-size=8192
126 EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
127 PROFILE: ${{ inputs.profile }}
128 BUILD_TAG: ${{ inputs.tag }}
129 steps:
130 - name: Checkout
131 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
132 with:
133 ref: ${{ inputs.sha }}
134 fetch-depth: 0
135​
136 # The steps below run dependency and build scripts; they get no token.
137 - name: Drop checkout credentials
138 uses: ./.github/actions/drop-checkout-credentials
139​
140 # A queued run can follow a build of the same fingerprint; manual runs always build.
141 - id: record
142 name: Check build record
143 env:
144 FORCE: ${{ github.event_name == 'workflow_dispatch' }}
145 run: |
146 if [ "$FORCE" != "true" ] && [ -n "$(git tag -l "$BUILD_TAG")" ]; then
147 echo "built=true" >> "$GITHUB_OUTPUT"
148 echo ":white_check_mark: ios: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY"
149 fi
150​
151 - name: Build
152 if: steps.record.outputs.built != 'true'
153 uses: ./.github/actions/eas-local-build
154 with:
155 platform: ios
156 profile: ${{ env.PROFILE }}
157 environment: production
158 expo-token: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
159 output: ${{ runner.temp }}/t3code.ipa
160 sourcemaps-r2: ${{ secrets.MOBILE_SOURCEMAPS_R2 }}
161​
162 - id: submit
163 name: Submit to App Store Connect
164 if: steps.record.outputs.built != 'true'
165 working-directory: apps/mobile
166 run: eas submit --platform ios --profile "$PROFILE" --path "$RUNNER_TEMP/t3code.ipa" --non-interactive
167​
168 # The tag means "delivered", so it follows the submit. If it can't be
169 # pushed, the next merge rebuilds with a new build number; nothing is lost.
170 record:
171 name: Record build
172 needs: [android, ios]
173 if: ${{ !cancelled() && (needs.android.outputs.submitted == 'true' || needs.ios.outputs.submitted == 'true') }}
174 runs-on: blacksmith-2vcpu-ubuntu-2404
175 timeout-minutes: 5
176 permissions:
177 contents: write # pushes the build record tag
178 env:
179 BUILD_TAG: ${{ inputs.tag }}
180 steps:
181 # The workflow's own commit, so the action below is this workflow's. The
182 # built commit is passed as data.
183 - name: Checkout
184 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
185 with:
186 fetch-depth: 0
187​
188 - name: Record build
189 uses: ./.github/actions/record-build-tag
190 with:
191 tag: ${{ inputs.tag }}
192 commit: ${{ inputs.sha }}
193 token: ${{ github.token }}
194​
195 - name: Summarize
196 env:
197 PLATFORM: ${{ inputs.platform }}
198 run: |
199 echo ":rocket: $PLATFORM: submitted and recorded \`$BUILD_TAG\`" >> "$GITHUB_STEP_SUMMARY"