-
Notifications
You must be signed in to change notification settings - Fork 35
305 lines (274 loc) · 12.1 KB
/
Copy pathios-testflight-release.yml
File metadata and controls
305 lines (274 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: ios-release
on:
workflow_dispatch:
inputs:
destination:
description: Where to publish the build and App Store assets
required: true
default: testflight
type: choice
options:
- testflight
- app-store-assets
- app-store
submit_for_review:
description: Submit the App Store version for review after upload
required: true
default: false
type: boolean
build_number:
description: Exact processed TestFlight build (required for app-store)
required: false
type: string
screenshot_style:
description: Screenshot presentation to upload
required: true
default: framed
type: choice
options:
- raw
- framed
workflow_run:
workflows: [Release Standalone]
types: [completed]
branches: [main]
concurrency:
group: ios-release-${{ github.event.workflow_run.head_sha || github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
check:
name: Check whether an iOS build should publish
runs-on: ubuntu-latest
outputs:
destination: ${{ steps.release.outputs.destination }}
build-number: ${{ steps.release.outputs.build-number }}
publish: ${{ steps.release.outputs.publish }}
source-ref: ${{ steps.release.outputs.source-ref }}
version: ${{ steps.release.outputs.version }}
steps:
- name: Checkout release source
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.ref }}
- name: Resolve release intent
id: release
env:
GH_TOKEN: ${{ github.token }}
INPUT_BUILD_NUMBER: ${{ inputs.build_number }}
INPUT_DESTINATION: ${{ inputs.destination }}
UPSTREAM_CONCLUSION: ${{ github.event.workflow_run.conclusion }}
UPSTREAM_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
set -euo pipefail
VERSION=$(node -p "require('./standalone/webapp/package.json').version")
SOURCE_REF=$(git rev-parse HEAD)
{
echo "version=$VERSION"
echo "source-ref=$SOURCE_REF"
echo "build-number=$INPUT_BUILD_NUMBER"
} >> "$GITHUB_OUTPUT"
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
if [ "$INPUT_DESTINATION" = "app-store" ] &&
! [[ "$INPUT_BUILD_NUMBER" =~ ^[0-9]+$ ]]; then
echo "::error::Enter the exact numeric TestFlight build number for App Store preparation."
exit 1
fi
{
echo "destination=$INPUT_DESTINATION"
echo "publish=true"
} >> "$GITHUB_OUTPUT"
exit 0
fi
echo "destination=testflight" >> "$GITHUB_OUTPUT"
if [ "$UPSTREAM_CONCLUSION" != "success" ]; then
echo "::notice::Standalone release did not succeed; skipping TestFlight."
echo "publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi
RELEASE_SHA=$(
gh release view "v$VERSION" \
--repo "$GITHUB_REPOSITORY" \
--json targetCommitish \
--jq .targetCommitish 2>/dev/null || true
)
if [ "$RELEASE_SHA" != "$UPSTREAM_SHA" ]; then
echo "::notice::v$VERSION was not released from $UPSTREAM_SHA; skipping TestFlight."
echo "publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if gh api \
"repos/$GITHUB_REPOSITORY/git/ref/tags/ios-testflight@$VERSION" \
>/dev/null 2>&1; then
echo "::notice::iOS $VERSION is already marked as uploaded to TestFlight."
echo "publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "publish=true" >> "$GITHUB_OUTPUT"
release:
needs: check
if: needs.check.outputs.publish == 'true'
runs-on: [self-hosted, macOS]
timeout-minutes: 60
permissions:
contents: write
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ needs.check.outputs.source-ref }}
- name: Set up Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version-file: ".nvmrc"
- name: Install pnpm
uses: pnpm/action-setup@ac6db6d3c1f721f886538a378a2d73e85697340a # v6.0.8
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Validate App Store metadata and public links
if: needs.check.outputs.destination != 'testflight'
working-directory: standalone/webapp
run: pnpm appstore:metadata:validate
- name: Install Ruby gems (fastlane + cocoapods)
working-directory: standalone/webapp
run: |
eval "$(/opt/homebrew/bin/rbenv init - --no-rehash bash)"
bundle install
# Persist rbenv shims on PATH so bundle, pod, and fastlane are
# resolvable in every subsequent step without re-init.
echo "$(rbenv root)/shims" >> "$GITHUB_PATH"
- name: Build library + web assets
run: pnpm run build:lib && pnpm --filter @tumaet/webapp run build
- name: Add iOS platform (if missing)
working-directory: standalone/webapp
run: |
if [ ! -d "ios" ]; then
pnpm capacitor:add:ios
fi
- name: Capacitor sync (iOS)
working-directory: standalone/webapp
# Bake the live-update signing public key into the app so the updater
# strictly rejects any bundle it can't verify. Unset (e.g. forks) → the
# feature is simply disabled, not insecure.
env:
CAPGO_PUBLIC_KEY: ${{ vars.CAPGO_PUBLIC_KEY }}
# Fail the build if the signing key is missing rather than shipping
# OTA with signature enforcement silently disabled.
CAPGO_REQUIRE_SIGNING: "true"
run: pnpm exec cap sync ios
- name: Resolve marketing version and build number
if: needs.check.outputs.destination == 'testflight'
run: |
MARKETING_VERSION=$(node -p "require('./standalone/webapp/package.json').version")
echo "MARKETING_VERSION=$MARKETING_VERSION" >> "$GITHUB_ENV"
echo "BUILD_NUMBER=$(date +'%Y%m%d%H%M')" >> "$GITHUB_ENV"
- name: Prepare licensed Apple product bezels
if: needs.check.outputs.destination != 'testflight' && inputs.screenshot_style == 'framed'
working-directory: standalone/webapp
run: pnpm run appstore:screenshots:prepare-frames
- name: Capture iPhone and iPad App Store screenshots
if: needs.check.outputs.destination != 'testflight'
working-directory: standalone/webapp
env:
APP_STORE_SCREENSHOT_STYLE: ${{ inputs.screenshot_style }}
run: bundle exec fastlane screenshots
- name: Upload App Store screenshot review
if: needs.check.outputs.destination != 'testflight'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ios-app-store-screenshot-review
path: |
standalone/webapp/fastlane/screenshots/
standalone/webapp/fastlane/screenshots-framed/
standalone/webapp/fastlane/screenshots-review.html
if-no-files-found: error
retention-days: 14
- name: Build iOS app (Fastlane)
if: needs.check.outputs.destination == 'testflight'
working-directory: standalone/webapp
env:
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
MARKETING_VERSION: ${{ env.MARKETING_VERSION }}
MATCH_GITLAB_AUTH: ${{ secrets.IOS_MATCH_GITLAB_AUTH }}
MATCH_PASSWORD: ${{ secrets.IOS_MATCH_PASSWORD }}
MATCH_GIT_URL: ${{ vars.IOS_MATCH_GIT_URL }}
API_KEY_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_KEY_ID }}
API_KEY_ISSUER_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
API_KEY_PASSWORD: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_PASSWORD }}
# The lane rebuilds and re-syncs the web bundle before archiving, so the
# signing key must be present here too — otherwise the archived binary
# would accept unsigned live updates.
CAPGO_PUBLIC_KEY: ${{ vars.CAPGO_PUBLIC_KEY }}
CAPGO_REQUIRE_SIGNING: "true"
run: bundle exec fastlane build
- name: Upload to TestFlight (Fastlane)
if: needs.check.outputs.destination == 'testflight'
working-directory: standalone/webapp
env:
API_KEY_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_KEY_ID }}
API_KEY_ISSUER_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
API_KEY_PASSWORD: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_PASSWORD }}
run: bundle exec fastlane release
- name: Upload App Store metadata and screenshots (Fastlane)
if: needs.check.outputs.destination == 'app-store-assets'
working-directory: standalone/webapp
env:
APP_STORE_VERSION: ${{ needs.check.outputs.version }}
API_KEY_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_KEY_ID }}
API_KEY_ISSUER_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
API_KEY_PASSWORD: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_PASSWORD }}
APP_STORE_SCREENSHOT_STYLE: ${{ inputs.screenshot_style }}
# Optional: App Review contact. Unset secrets are skipped, leaving the
# existing App Store Connect values untouched.
APP_REVIEW_FIRST_NAME: ${{ secrets.IOS_APP_REVIEW_FIRST_NAME }}
APP_REVIEW_LAST_NAME: ${{ secrets.IOS_APP_REVIEW_LAST_NAME }}
APP_REVIEW_EMAIL: ${{ secrets.IOS_APP_REVIEW_EMAIL }}
APP_REVIEW_PHONE: ${{ secrets.IOS_APP_REVIEW_PHONE }}
run: bundle exec fastlane store_assets
- name: Prepare App Store version from the tested TestFlight build (Fastlane)
if: needs.check.outputs.destination == 'app-store'
working-directory: standalone/webapp
env:
APP_STORE_SCREENSHOT_STYLE: ${{ inputs.screenshot_style }}
APP_STORE_VERSION: ${{ needs.check.outputs.version }}
BUILD_NUMBER: ${{ needs.check.outputs.build-number }}
API_KEY_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_KEY_ID }}
API_KEY_ISSUER_ID: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
API_KEY_PASSWORD: ${{ secrets.IOS_APP_STORE_CONNECT_API_KEY_PASSWORD }}
SUBMIT_FOR_REVIEW: ${{ inputs.submit_for_review }}
# Optional: App Review contact. Unset secrets are skipped, leaving the
# existing App Store Connect values untouched.
APP_REVIEW_FIRST_NAME: ${{ secrets.IOS_APP_REVIEW_FIRST_NAME }}
APP_REVIEW_LAST_NAME: ${{ secrets.IOS_APP_REVIEW_LAST_NAME }}
APP_REVIEW_EMAIL: ${{ secrets.IOS_APP_REVIEW_EMAIL }}
APP_REVIEW_PHONE: ${{ secrets.IOS_APP_REVIEW_PHONE }}
run: bundle exec fastlane release_app_store
- name: Upload IPA artifact
if: always() && needs.check.outputs.destination == 'testflight'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ios-ipa
path: standalone/webapp/build/*.ipa
retention-days: 7
- name: Mark version as uploaded to TestFlight
if: success() && needs.check.outputs.destination == 'testflight'
env:
GH_TOKEN: ${{ github.token }}
SOURCE_REF: ${{ needs.check.outputs.source-ref }}
VERSION: ${{ needs.check.outputs.version }}
run: |
if gh api \
"repos/$GITHUB_REPOSITORY/git/ref/tags/ios-testflight@$VERSION" \
>/dev/null 2>&1; then
echo "::notice::ios-testflight@$VERSION already exists."
exit 0
fi
gh api \
--method POST \
"repos/$GITHUB_REPOSITORY/git/refs" \
-f ref="refs/tags/ios-testflight@$VERSION" \
-f sha="$SOURCE_REF"