-
Notifications
You must be signed in to change notification settings - Fork 2.2k
345 lines (344 loc) · 14.6 KB
/
master-push.yml
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
332
333
334
335
336
337
338
339
340
341
342
343
344
name: Prepare Release
on:
workflow_dispatch:
push:
branches:
- "master"
- "release/**"
env:
XCODE_VERSION: "['14.2', '14.3.1', '15.1', '15.2', '15.3']"
# Github actions doesn't have Xcode 15.3 on any runners yet, so we can't run
# installation tests for it
XCODE_TEST_VERSIONS: "['14.2', '14.3.1', '15.1', '15.2']"
PLATFORM: "['ios', 'osx', 'watchos', 'tvos', 'catalyst', 'visionos']"
BUILD_PLATFORM: "['ios', 'iossimulator', 'osx', 'watchos', 'watchossimulator', 'tvos', 'tvossimulator', 'catalyst', 'visionos', 'visionossimulator']"
DOC_VERSION: '15.2'
RELEASE_VERSION: '15.2'
TEST_VERSION: '15.2'
jobs:
cleanup: # Clean-up XCode cloud workflows, before running the pipeline
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Token
id: token
run: |
token=$(echo $(ruby ./scripts/xcode_cloud_helper.rb --issuer-id ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} --key-id ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} --pk "${{ secrets.APPLE_STORE_CONNECT_API_KEY }}" get-token))
echo "TOKEN=$token" >> $GITHUB_OUTPUT
- name: Clean up release-packages xcode cloud workflows
run: |
ruby ./scripts/xcode_cloud_helper.rb clean-up-release-workflows -t ${{ steps.token.outputs.TOKEN }}
prepare:
runs-on: ubuntu-latest
name: Prepare outputs
needs: [cleanup]
outputs:
XCODE_VERSIONS_MATRIX: ${{ env.XCODE_VERSION }}
XCODE_TEST_VERSIONS_MATRIX: ${{ env.XCODE_TEST_VERSIONS }}
BUILD_PLATFORM_MATRIX: ${{ env.BUILD_PLATFORM }}
PLATFORM_MATRIX: ${{ env.PLATFORM }}
VERSION: ${{ steps.get-version.outputs.VERSION }}
steps:
- name: Compute outputs
run: |
echo "XCODE_VERSIONS_MATRIX=${{ env.XCODE_VERSION }}" >> $GITHUB_OUTPUT
echo "PLATFORM_MATRIX=${{ env.PLATFORM }}" >> $GITHUB_OUTPUT
echo "BUILD_PLATFORM_MATRIX=${{ env.BUILD_PLATFORM }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
- name: Read SDK version
id: get-version
run: |
version="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${GITHUB_WORKSPACE}/dependencies.list")"
echo "VERSION=$version" >> $GITHUB_OUTPUT
build-docs:
runs-on: macos-14
name: Package docs
needs: prepare
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ env.DOC_VERSION }}.app
- name: Prepare docs for packaging
run: bundle exec sh -x build.sh release-package-docs
- name: Upload docs to artifacts library
uses: actions/upload-artifact@v4
with:
name: realm-docs
path: docs/realm-docs.zip
build-examples:
runs-on: macos-14
name: Package examples
needs: prepare
steps:
- uses: actions/checkout@v4
- name: Prepare examples for packaging
run: sh -x build.sh release-package-examples
- name: Upload examples to artifacts library
uses: actions/upload-artifact@v4
with:
name: realm-examples
path: realm-examples.zip
build-product: # Creates framework for each platform, xcode version, target and configuration
runs-on: macos-14
name: Package framework
needs: prepare
strategy:
max-parallel: 20 # Blocks of 20, therefore if any of the build fails, we don't get a lot of XCode Clouds builds hanging, which are expensive.
matrix:
platform: ${{ fromJSON(needs.prepare.outputs.BUILD_PLATFORM_MATRIX) }}
xcode-version: ${{ fromJSON(needs.prepare.outputs.XCODE_VERSIONS_MATRIX) }}
configuration: [release, static]
exclude:
- platform: osx
configuration: static
- platform: tvos
configuration: static
- platform: watchos
configuration: static
- platform: visionos
configuration: static
- platform: catalyst
configuration: static
- platform: tvossimulator
configuration: static
- platform: watchossimulator
configuration: static
- platform: visionossimulator
configuration: static
- platform: visionos
xcode-version: 14.2
- platform: visionossimulator
xcode-version: 14.2
- platform: visionos
xcode-version: 14.3.1
- platform: visionossimulator
xcode-version: 14.3.1
- platform: visionos
xcode-version: 15.1
- platform: visionossimulator
xcode-version: 15.1
steps:
- uses: actions/checkout@v4
- name: Get Token
id: token
run: |
token=$(ruby ./scripts/xcode_cloud_helper.rb --issuer-id ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} --key-id ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} --pk "${{ secrets.APPLE_STORE_CONNECT_API_KEY }}" get-token)
echo "TOKEN=$token" >> $GITHUB_OUTPUT
- name: Creates on demand XCode Cloud's workflows with a build action
id: create-workflow
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: |
workflow_id=$(ruby ./scripts/xcode_cloud_helper.rb create-workflow release-package-build ${{ matrix.platform }} ${{ matrix.xcode-version }} RealmSwift ${{ matrix.configuration }} -t ${{ steps.token.outputs.TOKEN }})
echo "WORKFLOW_ID=$workflow_id" >> $GITHUB_OUTPUT
- name: Runs the XCode Cloud workflow created by the previous step
id: build-run
uses: nick-fields/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: |
build_run_id=$(ruby ./scripts/xcode_cloud_helper.rb build-workflow ${{ steps.create-workflow.outputs.WORKFLOW_ID }} ${{ github.ref_name }} -t ${{ steps.token.outputs.TOKEN }})
echo "BUILD_RUN_ID=$build_run_id" >> $GITHUB_OUTPUT
- name: Check build status and wait for it to finish
uses: nick-fields/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: |
while [ "$status" != 'COMPLETE' ]
do
token=$(ruby ./scripts/xcode_cloud_helper.rb --issuer-id ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} --key-id ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} --pk "${{ secrets.APPLE_STORE_CONNECT_API_KEY }}" get-token)
status=$(ruby ./scripts/xcode_cloud_helper.rb get-build-status ${{ steps.build-run.outputs.BUILD_RUN_ID }} -t $token)
echo "Status $status"
sleep 20
done
completion_status=$(ruby ./scripts/xcode_cloud_helper.rb get-build-result ${{ steps.build-run.outputs.BUILD_RUN_ID }} -t $token)
echo "Completion Status $completion_status"
if [ "$completion_status" != 'SUCCEEDED' ]; then
echo "XCode Cloud build failed"
ruby ./scripts/xcode_cloud_helper.rb print-build-logs ${{ steps.build-run.outputs.BUILD_RUN_ID }} -t $token
exit 1
fi
ruby ./scripts/xcode_cloud_helper.rb print-build-logs ${{ steps.build-run.outputs.BUILD_RUN_ID }} -t $token
- name: Download framework package from XCode Cloud artifacts
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: |
token=$(ruby ./scripts/xcode_cloud_helper.rb --issuer-id ${{ secrets.APPLE_STORE_CONNECT_ISSUER_ID }} --key-id ${{ secrets.APPLE_STORE_CONNECT_KEY_ID }} --pk "${{ secrets.APPLE_STORE_CONNECT_API_KEY }}" get-token)
ruby ./scripts/xcode_cloud_helper.rb download-artifact ${{ steps.build-run.outputs.BUILD_RUN_ID }} -t $token
- name: Upload framework
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.platform }}-${{ matrix.xcode-version }}-${{ matrix.configuration }}
path: xcode-cloud-build-${{ steps.build-run.outputs.BUILD_RUN_ID }}.zip
compression-level: 0
package-xcframework-platform: # Creates xcframework for each platform and xcode version
runs-on: macos-14
name: Package xcframework for platform
needs: [build-product, prepare]
strategy:
matrix:
platform: ${{ fromJSON(needs.prepare.outputs.PLATFORM_MATRIX) }}
xcode-version: ${{ fromJSON(needs.prepare.outputs.XCODE_VERSIONS_MATRIX) }}
exclude:
- platform: visionos
xcode-version: 14.2
- platform: visionos
xcode-version: 14.3.1
- platform: visionos
xcode-version: 15.1
steps:
- uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app
- name: Restore frameworks
uses: actions/download-artifact@v4
with:
pattern: build-${{ matrix.platform }}*-${{ matrix.xcode-version }}-*
- name: Create xcframework
run: sh -x build.sh release-create-xcframework-${{ matrix.xcode-version }} ${{ matrix.platform }}
- name: Upload xcframework
uses: actions/upload-artifact@v4
with:
name: realm-${{ matrix.platform }}-${{ matrix.xcode-version }}
path: realm-${{ matrix.platform }}-${{ matrix.xcode-version }}.zip
package-release: # Creates xcframework for each platform and xcode version
runs-on: macos-14
name: Package release file
needs: [package-xcframework-platform, prepare]
steps:
- uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app
- name: Restore packages xcframeworks
uses: actions/download-artifact@v4
with:
pattern: realm-*
- name: Create release
run: sh -x build.sh release-package
- name: Upload release artifactss
uses: actions/upload-artifact@v4
with:
name: release-package
path: pkg/*.zip
- name: Upload release for testing
uses: actions/upload-artifact@v4
with:
name: realm-swift-${{ needs.prepare.outputs.VERSION }}
path: pkg/realm-swift-${{ needs.prepare.outputs.VERSION }}.zip
test-package-examples:
runs-on: macos-14
name: Test examples
needs: [package-release, prepare]
steps:
- uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ env.TEST_VERSION }}.app
- name: Restore release
uses: actions/download-artifact@v4
with:
name: realm-swift-${{ needs.prepare.outputs.VERSION }}
- name: Test examples
run: sh -x build.sh release-test-examples
test-ios-static:
runs-on: macos-14
name: Run tests on iOS with configuration Static
needs: package-release
steps:
- uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ env.TEST_VERSION }}.app
- name: Test ios static
run: sh -x build.sh test-ios-static
test-osx-static:
runs-on: macos-14
name: Run tests on macOS
needs: package-release
steps:
- uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ env.TEST_VERSION }}.app
- name: Test osx static
run: |
export REALM_DISABLE_METADATA_ENCRYPTION=1
sh -x build.sh test-osx
test-installation:
runs-on: macos-14
name: Run installation test
needs: [package-release, prepare]
strategy:
matrix:
platform: ${{ fromJSON(needs.prepare.outputs.PLATFORM_MATRIX) }}
installation: [cocoapods, spm, carthage, xcframework]
linkage: [dynamic, static]
exclude:
- platform: visionos
- platform: catalyst
installation: carthage
- installation: carthage
linkage: static
- installation: xcframework
linkage: static
include:
- platform: ios
installation: xcframework
linkage: static
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ env.TEST_VERSION }}.app
- name: Restore release
uses: actions/download-artifact@v4
if: ${{ matrix.installation == 'xcframework' }}
with:
name: realm-${{ matrix.platform }}-${{ env.TEST_VERSION }}
- name: Unzip package release
if: ${{ matrix.installation == 'xcframework' }}
run: |
mkdir -p build
unzip realm-${{ matrix.platform }}-${{ env.TEST_VERSION }}.zip -d build
- name: Run installation test
run: |
echo "REALM_TEST_BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT
cd examples/installation
bundle exec ./build.rb ${{ matrix.platform }} ${{ matrix.installation }} ${{ matrix.linkage }}
test-installation-xcframework:
runs-on: macos-13
name: Run installation test for xcframework
needs: [package-release, prepare]
env:
PLATFORM: 'osx'
strategy:
matrix:
xcode-version: ${{ fromJSON(needs.prepare.outputs.XCODE_TEST_VERSIONS_MATRIX) }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode-version }}.app
- name: Restore release
uses: actions/download-artifact@v4
with:
name: realm-${{ env.PLATFORM }}-${{ matrix.xcode-version }}
- name: Unzip package release
run: |
mkdir -p build
unzip realm-${{ env.PLATFORM }}-${{ matrix.xcode-version }}.zip -d build
- name: Run installation test
run: |
echo "REALM_TEST_BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT
cd examples/installation
bundle exec ./build.rb osx xcframework dynamic