Repository navigation
331 lines (296 loc) · 13.7 KB
/
Copy pathbuild-ios-release.yml
File metadata and controls
331 lines (296 loc) · 13.7 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# Builds the Logseq iOS app as a signed .ipa and uploads it to TestFlight via
# fastlane match + the App Store Connect API key. Modeled on logseq/logseq's
# build-ios-release.yml; signing ids and accounts are identical to the mobile
# app in logseq/logseq.
name: Build-iOS
on:
workflow_dispatch:
inputs:
git-ref:
description: "Release Git Ref (Which branch or tag to build?)"
required: true
default: "main"
testflight-distribution:
description: "TestFlight audience (Mobile Testers or internal groups only)"
type: choice
default: mobile-testers
options:
- mobile-testers
- internal
jobs:
duniverse:
name: Vendor duniverse
runs-on: ubuntu-26.04
timeout-minutes: 30
outputs:
source-revision: ${{ steps.checkout.outputs.commit }}
steps:
- uses: actions/checkout@v4
id: checkout
with:
ref: ${{ inputs.git-ref }}
- name: Load OCaml actions from the release workflow revision
env:
WORKFLOW_SHA: ${{ github.workflow_sha }}
run: |
# The selected app ref may predate these workflow actions.
if [[ "$(git rev-parse HEAD)" != "$WORKFLOW_SHA" ]]; then
git fetch --quiet --no-tags --depth=1 origin "$WORKFLOW_SHA"
git archive "$WORKFLOW_SHA" .github/actions/ocaml-tools .github/actions/ocaml-vendor | tar -xf -
fi
- uses: ./.github/actions/ocaml-vendor
with:
mode: prepare
build-app:
needs: duniverse
runs-on: xcode-27
timeout-minutes: 120
env:
LOGSEQ_OPAM_SWITCH: ${{ github.workspace }}
DUNE_CACHE: enabled
DUNE_CACHE_STORAGE_MODE: copy
GIT_TERMINAL_PROMPT: "0"
GIT_CONFIG_COUNT: 4
GIT_CONFIG_KEY_0: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_0: "git@github.com:"
GIT_CONFIG_KEY_1: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_1: "ssh://git@github.com/"
GIT_CONFIG_KEY_2: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_2: "git+ssh://git@github.com/"
# Keep the signing repository on SSH for its read-only deploy key.
GIT_CONFIG_KEY_3: url.ssh://git@github.com/logseq/certificates.git.insteadOf
GIT_CONFIG_VALUE_3: "ssh://git@github.com/logseq/certificates.git"
steps:
- uses: actions/checkout@v4
id: checkout
with:
ref: ${{ needs.duniverse.outputs.source-revision }}
- name: Load OCaml actions from the release workflow revision
env:
WORKFLOW_SHA: ${{ github.workflow_sha }}
run: |
# The selected app ref may predate these workflow actions.
if [[ "$(git rev-parse HEAD)" != "$WORKFLOW_SHA" ]]; then
git fetch --quiet --no-tags --depth=1 origin "$WORKFLOW_SHA"
git archive "$WORKFLOW_SHA" .github/actions/ocaml-tools .github/actions/ocaml-vendor | tar -xf -
fi
- name: Prepare signing repository access
run: |
set -o pipefail
: "${IOS_SIGNING_SSH_PRIVATE_KEY:?IOS_SIGNING_SSH_PRIVATE_KEY is required}"
umask 077
printf '%s\n' "$IOS_SIGNING_SSH_PRIVATE_KEY" > "$RUNNER_TEMP/logseq-signing-ci"
mkdir -p "$HOME/.ssh"
gh api meta --jq '.ssh_keys[] | "github.com " + .' >> "$HOME/.ssh/known_hosts"
GIT_SSH_COMMAND="ssh -i $RUNNER_TEMP/logseq-signing-ci -o IdentitiesOnly=yes -o BatchMode=yes" \
git ls-remote ssh://git@github.com/logseq/certificates.git HEAD > /dev/null
env:
GH_TOKEN: ${{ github.token }}
IOS_SIGNING_SSH_PRIVATE_KEY: ${{ secrets.IOS_SIGNING_SSH_PRIVATE_KEY }}
- name: Select Xcode 27.2
run: |
sudo xcode-select --switch /Applications/Xcode_27.2.app
xcodebuild -version
xcrun --sdk iphoneos --show-sdk-path
- name: System dependencies
run: brew install sdl2 sdl2_ttf
- name: Install Sentry CLI for release symbols
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
: "${SENTRY_AUTH_TOKEN:?SENTRY_AUTH_TOKEN is required to upload iOS release dSYMs}"
brew install sentry-cli
- uses: ./.github/actions/ocaml-tools
with:
image: xcode-27
- uses: ./.github/actions/ocaml-vendor
- name: Restore iOS OCaml toolchain
id: ios-toolchain
uses: actions/cache/restore@v4
with:
path: |
_build/apple-toolchains/ios/host-5.5.0
_build/apple-toolchains/ios/arm64-apple-ios17.0-5.5.0
_build/apple-toolchains/ios/libffi-arm64-apple-ios17.0
key: apple-toolchain-${{ runner.os }}-xcode27.2-ios-device-5.5.0-${{ hashFiles('scripts/bootstrap-ios-ocaml.sh', 'scripts/build-mobile-libffi.sh') }}
- name: Restore legacy iOS OCaml toolchain cache
id: ios-toolchain-legacy
if: steps.ios-toolchain.outputs.cache-primary-key != '' && steps.ios-toolchain.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: _build/apple-toolchains
key: ${{ steps.ios-toolchain.outputs.cache-primary-key }}
- name: Bootstrap iOS OCaml toolchain (device)
if: steps.ios-toolchain.outputs.cache-hit != 'true' && steps.ios-toolchain-legacy.outputs.cache-hit != 'true'
run: ./scripts/bootstrap-ios-ocaml.sh device
- name: Select build cache week
id: cache-week
run: date -u '+value=%G-W%V' >> "$GITHUB_OUTPUT"
- name: Restore iOS device Dune cache
id: ios-dune
uses: actions/cache/restore@v4
with:
path: ~/.cache/dune
key: ios-device-dune-v2-${{ runner.arch }}-xcode27.2-${{ steps.cache-week.outputs.value }}
restore-keys: |
ios-device-dune-v2-${{ runner.arch }}-xcode27.2-
ios-device-dune-v1-${{ runner.arch }}-xcode27.2-
- name: Restore iOS release Swift package downloads
id: swift-packages
# Sentry's binary artifacts are the bulk of this cache. Xcode can fetch
# newer source pins into the restored repositories during resolution.
uses: actions/cache/restore@v4
with:
path: |
apple/.build/release-source-packages/repositories
apple/.build/release-source-packages/artifacts
key: ios-release-swift-packages-v2-${{ runner.arch }}-xcode27.2-${{ hashFiles('apple/Package.swift', 'apple/Package.resolved') }}
- name: Build OCaml iOS core (device)
# Produces _build/ios-core/device/native-link-inputs.txt, which the
# fastlane beta lane exports as LOGSEQ_NATIVE_LINK_INPUTS so the
# SwiftPM manifest links the OCaml core into the archive.
run: opam exec -- env LOGSEQ_IOS_LINK_INPUTS_ONLY=1 ./scripts/build-mobile-ios-device.sh
- name: Save iOS OCaml toolchain
# Keep a completed toolchain even if a later compilation failed.
if: >-
always() && steps.ios-toolchain.outputs.cache-primary-key != '' &&
steps.ios-toolchain.outputs.cache-hit != 'true' &&
hashFiles('_build/apple-toolchains/ios/host-5.5.0/.logseq-toolchain-complete') != '' &&
hashFiles('_build/apple-toolchains/ios/arm64-apple-ios17.0-5.5.0/.logseq-toolchain-complete') != '' &&
hashFiles('_build/apple-toolchains/ios/libffi-arm64-apple-ios17.0/.libffi-*-complete') != '' &&
hashFiles('_build/apple-toolchains/ios/libffi-arm64-apple-ios17.0/lib/libffi.a') != ''
uses: actions/cache/save@v4
with:
path: |
_build/apple-toolchains/ios/host-5.5.0
_build/apple-toolchains/ios/arm64-apple-ios17.0-5.5.0
_build/apple-toolchains/ios/libffi-arm64-apple-ios17.0
key: ${{ steps.ios-toolchain.outputs.cache-primary-key }}
- name: Bound the iOS device Dune cache
if: github.ref == 'refs/heads/main' && steps.ios-dune.outputs.cache-hit != 'true'
run: opam exec -- dune cache trim --size=512MiB
- name: Save iOS device Dune cache
if: github.ref == 'refs/heads/main' && steps.ios-dune.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.cache/dune
key: ${{ steps.ios-dune.outputs.cache-primary-key }}
- name: Restore bundler gems
uses: actions/cache/restore@v4
with:
path: apple/App/vendor/bundle
key: bundler-${{ hashFiles('apple/App/Gemfile', 'apple/App/Gemfile.lock', '.github/workflows/build-ios-release.yml') }}
- name: Setup build tools
run: |
sudo gem install bundler -v 2.7.2 --no-document
bundle _2.7.2_ config set --local path 'vendor/bundle'
bundle _2.7.2_ install
working-directory: ./apple/App
- name: Save bundler gems
uses: actions/cache/save@v4
with:
path: apple/App/vendor/bundle
key: bundler-${{ hashFiles('apple/App/Gemfile', 'apple/App/Gemfile.lock', '.github/workflows/build-ios-release.yml') }}
- name: Build and upload iOS app
run: |
# Xcode's system rsync must also resolve its child process to the
# system version, rather than an incompatible Homebrew rsync.
mkdir -p "$RUNNER_TEMP/apple-export-tools"
ln -s /usr/bin/rsync "$RUNNER_TEMP/apple-export-tools/rsync"
export PATH="$RUNNER_TEMP/apple-export-tools:$PATH"
df -h .
bundle exec fastlane beta
working-directory: ./apple/App
env:
APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }}
APP_STORE_CONNECT_API_KEY_IS_KEY_CONTENT_BASE64: true
SLACK_URL: ${{ secrets.SLACK_URL }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_URL: ssh://git@github.com/logseq/certificates.git
MATCH_GIT_PRIVATE_KEY: ${{ runner.temp }}/logseq-signing-ci
GYM_CLONED_SOURCE_PACKAGES_PATH: ${{ github.workspace }}/apple/.build/release-source-packages
XCODE_XCARGS: "-allowProvisioningUpdates"
- name: Collect iOS export diagnostics
if: always()
run: |
python3 - <<'PY'
import os
from pathlib import Path
import shutil
root = Path("_build/ios-release/diagnostics")
root.mkdir(parents=True, exist_ok=True)
for source in Path(os.environ["TMPDIR"]).glob("*.xcdistributionlogs"):
shutil.copytree(source, root / source.name, dirs_exist_ok=True)
logs = Path.home() / "Library/Logs/gym"
if logs.exists():
shutil.copytree(logs, root / "gym", dirs_exist_ok=True)
for path in root.rglob("IDEDistributionPipeline.log"):
lines = path.read_text(errors="replace").splitlines()
failures = [line for line in lines if any(word in line.lower() for word in ("rsync", "error:", "failed"))]
for line in failures[-30:]:
print(line)
PY
df -h .
- name: Save iOS verification reports
if: always()
uses: actions/upload-artifact@v4
with:
name: ios-verification-${{ github.run_id }}
path: _build/ios-release/*verification.json
if-no-files-found: ignore
retention-days: 7
- name: Save verified iOS release and diagnostics
if: always() && github.event.repository.private
uses: actions/upload-artifact@v4
with:
name: ios-release-${{ github.run_id }}
path: |
_build/ios-release/*.ipa
_build/ios-release/*verification.json
_build/ios-release/diagnostics
retention-days: 7
- name: Save iOS release Swift package downloads
if: github.ref == 'refs/heads/main' && steps.swift-packages.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
apple/.build/release-source-packages/repositories
apple/.build/release-source-packages/artifacts
key: ${{ steps.swift-packages.outputs.cache-primary-key }}
distribute-testflight:
name: Distribute to TestFlight testers
needs: [duniverse, build-app]
runs-on: ubuntu-26.04
# The script waits up to 15 minutes before leaving time for assignment.
timeout-minutes: 20
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
# The selected app ref may predate the distribution script.
ref: ${{ github.workflow_sha }}
persist-credentials: false
- uses: actions/download-artifact@v4
with:
name: ios-verification-${{ github.run_id }}
path: verified-ios
- name: Install TestFlight API dependencies
run: |
python3 -m venv "$RUNNER_TEMP/testflight"
"$RUNNER_TEMP/testflight/bin/python" -m pip install --quiet 'PyJWT[crypto]==2.10.1'
- name: Distribute the verified iOS build
env:
ASC_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
ASC_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }}
SOURCE_REVISION: ${{ needs.duniverse.outputs.source-revision }}
TESTFLIGHT_DISTRIBUTION: ${{ inputs.testflight-distribution }}
run: |
"$RUNNER_TEMP/testflight/bin/python" -u scripts/distribute_ios_testflight.py \
--report verified-ios/ipa-verification.json \
--source-revision "$SOURCE_REVISION" \
--distribution "$TESTFLIGHT_DISTRIBUTION"