forked from aws-amplify/aws-sdk-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
485 lines (425 loc) · 15.7 KB
/
release.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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
name: Release
on:
push:
branches:
- release
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
extract-release-version:
name: Extract Release Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-release-version.outputs.result }}
steps:
- name: Extract release version
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
id: extract-release-version
with:
result-encoding: string
script: |
const matches = `${{ github.event.head_commit.message }}`.match(/[0-9]+\.[0-9]+\.[0-9]+/) ?? []
return matches.length > 0 ? matches[0] : ""
validate-version-format:
name: Validate Version Format
needs:
- extract-release-version
if: ${{ needs.extract-release-version.outputs.version != '' }}
runs-on: ubuntu-latest
steps:
- name: Validated
run: echo "Releasing new version ${{ needs.extract-release-version.outputs.version }}"
unit-test:
name: Unit Tests
needs:
- validate-version-format
uses: ./.github/workflows/unit-test.yml
with:
identifier: workflow-call-unit-test
integration-test:
name: Integration Tests
needs:
- validate-version-format
uses: ./.github/workflows/integ-test.yml
with:
identifier: workflow-call-integration-test
secrets: inherit
build-xcframeworks:
name: Build xcframeworks
runs-on: macos-12
needs:
- extract-release-version
- unit-test
- integration-test
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
- name: Build xcframework
run: |
# assert release version is not empty
[[ ! -z "$RELEASE_VERSION" ]] || exit 1
python3 ./CircleciScripts/create_xcframeworks.py
- name: Upload artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: xcframework
path: xcframeworks/
release-xcframeworks:
name: Release xcframeworks
runs-on: macos-12
environment: ReleaseArtifacts
needs:
- extract-release-version
- build-xcframeworks
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600
aws-region: us-east-1
role-session-name: "release-artifacts-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Download aratifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: xcframework
path: xcframeworks
- name: Checkout SPM Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
path: aws-sdk-ios-spm
repository: aws-amplify/aws-sdk-ios-spm
- name: Prepare xcframework archives
working-directory: ${{ github.workspace }}
run: |
pip3 install boto3
python3 CircleciScripts/prepare_xcframework_archives.py $RELEASE_VERSION
- name: Release xcframeworks
working-directory: ${{ github.workspace }}
run: |
python3 CircleciScripts/upload_xcframeworks.py \
${{ secrets.RELEASE_BUCKET }} \
$RELEASE_VERSION
- name: Upload SPM checksums
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: spm-checksum
path: ${{ github.workspace }}/aws-sdk-ios-spm/Package.swift
release-spm:
name: Release SPM
runs-on: macos-12
environment: Release
needs:
- extract-release-version
- release-xcframeworks
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout SPM Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
repository: aws-amplify/aws-sdk-ios-spm
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900
aws-region: us-east-1
role-session-name: "release-spm.${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
- name: Download SPM checksum
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: spm-checksum
path: /tmp/spm-checksum
- name: Post release xcframeworks
run: |
git config user.name aws-amplify-ops
git config user.email [email protected]
PAT=$(aws secretsmanager get-secret-value \
--secret-id "${{ secrets.SPM_DEPLOY_SECRET_ARN }}" \
| jq ".SecretString | fromjson | .Credential" | tr -d '"')
git checkout -b pre-release-$RELEASE_VERSION
cp /tmp/spm-checksum/Package.swift ${{ github.workspace }}/Package.swift
git add Package.swift
git commit -m "[release-spm]: Version and checksum update for $RELEASE_VERSION"
git push "https://${PAT}@github.com/aws-amplify/aws-sdk-ios-spm" pre-release-$RELEASE_VERSION
release-combined-xcframeworks:
name: Release combine xcframeworks
runs-on: macos-12
environment: ReleaseArtifacts
needs:
- extract-release-version
- release-spm
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
- name: Download built xcframeworks
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: xcframework
path: xcframeworks
- name: Make directory structure
id: make-release-folder
run: |
releaseFolder="aws-ios-sdk-${RELEASE_VERSION}"
echo "releaseFolder=$releaseFolder" >> "$GITHUB_OUTPUT"
mkdir -p "$releaseFolder"
mv "xcframeworks/output/XCF/" "$releaseFolder/frameworks"
rm -rf "xcframeworks/output/"
- name: Copy SDK resource files
env:
RELEASE_FOLDER: ${{ steps.make-release-folder.outputs.releaseFolder }}
run: |
python3 CircleciScripts/copy_resourcefiles.py "$(pwd)" "$(pwd)/${RELEASE_FOLDER}"
zip -r "${RELEASE_FOLDER}.zip" "$RELEASE_FOLDER"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900
aws-region: us-east-1
role-session-name: "release-artifacts-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
- name: Upload to S3
env:
RELEASE_FOLDER: ${{ steps.make-release-folder.outputs.releaseFolder }}
RELEASE_BUCKET: ${{ secrets.RELEASE_BUCKET }}
run: |
aws s3api put-object \
--bucket "$RELEASE_BUCKET" \
--key "aws-sdk-ios/${RELEASE_FOLDER}.zip" \
--body "${RELEASE_FOLDER}.zip" \
--content-disposition "attachment;filename=${RELEASE_FOLDER}.zip"
aws s3api put-object \
--bucket "$RELEASE_BUCKET" \
--key "aws-sdk-ios/latest/aws-ios-sdk.zip" \
--body "${RELEASE_FOLDER}.zip" \
--content-disposition "attachment;filename=${RELEASE_FOLDER}.zip"
- name: Invalidate cloudfront
env:
XCF_RELEASE_DISTRIBUTION_ID: ${{ secrets.XCF_RELEASE_DISTRIBUTION_ID }}
run: |
python3 CircleciScripts/cloudfront_invalidate.py \
"$XCF_RELEASE_DISTRIBUTION_ID" \
"aws-sdk-ios/latest/aws-ios-sdk.zip"
release-tag:
name: Rlease tag
runs-on: macos-12
needs:
- extract-release-version
- release-combined-xcframeworks
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
- name: Release the tag to Github
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${process.env.RELEASE_VERSION}`,
sha: context.sha,
force: true
})
update-main-branch:
name: Update main branch
runs-on: ubuntu-latest
needs:
- extract-release-version
- release-tag
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Merge back to main branch
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr create \
--title "chore: sync release commits back to main [skip ci]" \
--body "sync release commits back to main branch, version $RELEASE_VERSION" \
--head release \
--base main
update-bump-sdk-version-branch:
name: Update bump_sdk_version branch
runs-on: ubuntu-latest
needs:
- extract-release-version
- release-tag
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: bump_sdk_version
- name: Update version file
run: echo "${RELEASE_VERSION}" > version
- name: Make version bump commit
run: |
git config user.name aws-amplify-ops
git config user.email [email protected]
git add version
git commit -m "bump version ${RELEASE_VERSION}"
git push origin HEAD:bump_sdk_version
release-doc:
name: Release docs
runs-on: macos-12
needs:
- extract-release-version
- update-main-branch
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
- name: Setup Ruby
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
with:
ruby-version: '3.2.1'
bundler-cache: true
- name: Generate documents
run: bash ./CircleciScripts/generate_documentation.sh
- name: Checkout gh-page branch
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: gh-pages
path: gh-pages
- name: Copy documents
working-directory: ${{ github.workspace }}/gh-pages
run: |
rm -rf docs/reference
mv ../docs_tmp docs/reference
- name: Checkin documents
working-directory: ${{ github.workspace }}/gh-pages
run: |
git config user.name aws-amplify-ops
git config user.email [email protected]
for dirPath in docs/reference/* ; do
sdkName=$( basename "$dirPath" )
git add "$dirPath" && git commit -m "Update API documentation for ${sdkName} ${RELEASE_VERSION}"
git prune
done
git push origin gh-pages
add-doc-tag:
name: Add doc tag
runs-on: macos-12
needs:
- extract-release-version
- release-doc
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: gh-pages
persist-credentials: false
- name: Add documentation tags to gh-pages
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
console.log(`Adding documentation tags...`)
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${process.env.RELEASE_VERSION}_api_docs`,
sha: context.sha
})
release-cocoapods:
name: Release Cocoapods
runs-on: macos-12
needs:
- add-doc-tag
environment: Release
env:
COCOAPODS_SECRET_ARN: ${{ secrets.COCOAPODS_SECRET_ARN }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
- name: Setup Ruby
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
with:
ruby-version: '3.2.1'
bundler-cache: true
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 1200
aws-region: us-east-1
role-session-name: "release-cocoapods-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
- name: Publisher new version to CocoaPods
run: |
python3 ./CircleciScripts/cocoapods_release.py
release-carthage:
name: Release Carthage
runs-on: macos-12
needs:
- extract-release-version
- add-doc-tag
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
- name: Download aratifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: xcframework
path: xcframeworks
- name: Create Carthage archive
run: python3 ./CircleciScripts/create_carthage_archive.py
- name: Upload Carthage archive to Github release
run: |
gh release create --draft \
--verify-tag \
--title "AWS SDK for iOS $RELEASE_VERSION" \
$RELEASE_VERSION './aws-sdk-ios-carthage.framework.zip'
bump-ios-sampleapp-version:
name: 'Bump iOS sample App version'
runs-on: macos-12
needs:
- release-xcframeworks
- release-cocoapods
- release-tag
steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
persist-credentials: false
- name: Checkout iOS Sample Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
repository: awslabs/aws-sdk-ios-samples
path: aws-sdk-ios-samples
persist-credentials: false
- name: Build projects
run: python3 CircleciScripts/build_iossample.py ${{ github.workspace }}/aws-sdk-ios-samples