-
Notifications
You must be signed in to change notification settings - Fork 10
299 lines (254 loc) · 9.49 KB
/
create-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
name: Create Release
env:
ARCHIVE_QUIET_MODE: 1
on:
push:
branches:
- "release/*"
workflow_dispatch:
inputs:
rc_version:
description: "The release candidate version to create"
required: true
is_production_ready:
description: "Is the release candidate production ready"
type: boolean
default: false
permissions:
id-token: write
contents: write
packages: read
jobs:
extractor:
name: Extract elements from context
runs-on: ubuntu-latest
timeout-minutes: 5
env:
RC_VERSION: ${{ github.event.inputs.rc_version }}
IS_PRODUCTION_READY: ${{ github.event.inputs.is_production_ready }}
outputs:
rc_version: ${{ steps.rc_version_extractor.outputs.rc_version }}
is_production_ready: ${{ env.IS_PRODUCTION_READY }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Define Production Readiness
run: |
if [ -z "$IS_PRODUCTION_READY" ]; then
echo "IS_PRODUCTION_READY=false" >> $GITHUB_ENV
fi
echo "Production readiness determined: $IS_PRODUCTION_READY"
- name: Validate and Extract RC Version Number
id: rc_version_extractor
run: |
# If the workflow wasn't triggered manually, extract the version number either from branch or tag
# (depending the event which triggered the workflow).
if [ -z "$RC_VERSION" ]; then
if [[ "${{ github.ref_type }}" == "branch" ]]; then
BRANCH_VERSION=${GITHUB_REF_NAME##release/}
RC_VERSION=$BRANCH_VERSION
fi
fi
# Production-ready versions should always follow a "definitive" version format:
# - xx.yy.zz
# But, non-production-ready versions support having pre-release versions, like:
# - x.y.z-rc1
if [ "$IS_PRODUCTION_READY" == "true" ]; then
if ! [[ "$RC_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: RC_VERSION of '$RC_VERSION' is not in the correct production-ready format."
exit 1
fi
else
if ! [[ "$RC_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$ ]]; then
echo "Error: RC_VERSION of '$RC_VERSION' is not compliant with pre-release semver."
exit 1
fi
VERSION_COUNTER=1
while [ ! -z $(git tag -l ${RC_VERSION}-rc${VERSION_COUNTER}) ]; do
VERSION_COUNTER=$((VERSION_COUNTER + 1))
done
RC_VERSION="${RC_VERSION}-rc${VERSION_COUNTER}"
fi
echo "rc_version=$RC_VERSION" >> $GITHUB_OUTPUT
echo "Using RC_VERSION of $RC_VERSION"
build_release_candidate:
name: Bump Version and Build Release
runs-on: macos-14
timeout-minutes: 60
needs:
- extractor
env:
RC_VERSION: ${{ needs.extractor.outputs.rc_version }}
IS_PRODUCTION_READY: ${{ needs.extractor.outputs.is_production_ready }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump Version
run: |
echo "Bumping version to '$RC_VERSION'"
bin/version_bump $RC_VERSION
# DEV: show diff
git diff
if [[ `git status --porcelain` ]]; then
echo "VERSION_BUMPED=true" >> $GITHUB_ENV
fi
- name: Commit Version Changes
if: env.VERSION_BUMPED == 'true'
run: |
git config --global user.name "embrace-ci"
git config --global user.email "embrace-ci@users.noreply.github.com"
git add EmbraceIO.podspec \
Sources/EmbraceCommonInternal/EmbraceMeta.swift
git diff --cached
git commit -m "CI/CD: Bumps version to '$RC_VERSION'"
git push
- name: Select Xcode 15
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: Install Mise
run: |
# Install Mise
curl https://mise.jdx.dev/install.sh | sh
echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH
echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH
- name: Build XCFramework
run: |
eval "$(~/.local/bin/mise activate bash)" >> ~/.bashrc
echo "$PATH"
# mise doctor
./bin/build_xcframeworks.sh
# TODO: Finish this step
- name: Sign XCFramework
run: echo "We're not going to sign the xcframeworks at this moment. Will do it later"
- name: Zip XCFrameworks
run: |
DIR=$(pwd -P)
cd build; zip -r "$DIR/xcframeworks.zip" xcframeworks
- name: Store XCFrameworks
uses: actions/upload-artifact@v4
with:
name: Embrace-Universal Build Artifacts
path: xcframeworks.zip
- name: Tag the release candidate version
run: |
git tag $RC_VERSION
git push origin $RC_VERSION
archive_cocoapods_artifacts:
name: Archive Cocoapods Artifacts
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- extractor
- build_release_candidate
env:
RC_VERSION: ${{ needs.extractor.outputs.rc_version }}
steps:
- name: Determine latest embrace_support.zip version
env:
GH_TOKEN: ${{ github.token }}
run: |
version=$(gh release list --repo embrace-io/action-symbol-upload --json tagName --jq '.[] | select(.tagName | startswith("embrace_support-")) | .tagName' --order desc | head -1)
echo "Using tool version ${version}"
echo "SUPPORT_TOOL=${version}" >> $GITHUB_ENV
- name: Download embrace_support.zip
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release --repo embrace-io/action-symbol-upload download ${{ env.SUPPORT_TOOL }} --pattern 'embrace_support-*' --clobber
- name: Verify and extract embrace_support.zip
run: |
if /usr/bin/shasum -a 256 -c ${{ env.SUPPORT_TOOL }}.zip.sha256; then
unzip -o ${{ env.SUPPORT_TOOL }}.zip
else
echo "Checksum verification failed, aborting."
exit 1
fi
- name: Download Artifacts - XCFrameworks
uses: actions/download-artifact@v4
with:
name: Embrace-Universal Build Artifacts
- name: Unzip Embrace-Universal Build Artifacts
run: unzip xcframeworks.zip
- name: Create Cocoapods Release Zip
run: |
DIR=$(pwd -P)
mkdir artifacts
chmod +x run.sh embrace_symbol_upload.darwin
mv run.sh embrace_symbol_upload.darwin artifacts/
cd artifacts; zip "$DIR/embrace_$RC_VERSION.zip" *; cd -;
zip "$DIR/embrace_$RC_VERSION.zip" -r xcframeworks/*; cd -;
- name: Store Cocoapods Artifacts
uses: actions/upload-artifact@v4
with:
name: Cocoapods Release Archive
path: embrace_${{ env.RC_VERSION }}.zip
create_github_release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs:
- extractor
- archive_cocoapods_artifacts
steps:
- name: Download Cocoapods Release Archive
uses: actions/download-artifact@v4
with:
name: Cocoapods Release Archive
path: cocoapods/
- name: Disable GitHub CLI Prompt if Enabled
run: |
if [ "$(gh config get prompt)" = "enabled" ]; then
gh config set prompt disabled
fi
- name: Create/Edit Release
env:
GITHUB_TOKEN: ${{ github.token }}
RC_VERSION: ${{ needs.extractor.outputs.rc_version}}
IS_PRODUCTION_READY: ${{ needs.extractor.outputs.is_production_ready }}
run: |
if gh release view --repo embrace-io/embrace-apple-sdk $RC_VERSION > /dev/null 2>&1; then
if [ "$IS_PRODUCTION_READY" == "false" ]; then
echo "Release $RC_VERSION already exists; editing..."
gh release upload $RC_VERSION cocoapods/embrace_$RC_VERSION.zip --clobber --repo embrace-io/embrace-apple-sdk --verify-tag
else
echo "Cannot update a production release"
exit 1
fi
else
echo "Creating Release $RC_VERSION in Github"
PRERELEASE_FLAG=""
if [ "$IS_PRODUCTION_READY" == "false" ]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create $RC_VERSION cocoapods/embrace_$RC_VERSION.zip --title "$RC_VERSION" $PRERELEASE_FLAG --repo embrace-io/embrace-apple-sdk --verify-tag
fi
push_podspec:
name: Push Podspec to Cocoapods
runs-on: macos-14
timeout-minutes: 10
needs:
- extractor
- create_github_release
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
RC_VERSION: ${{ needs.extractor.outputs.rc_version }}
IS_PRODUCTION_READY: ${{ needs.extractor.outputs.is_production_ready }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ needs.extractor.outputs.rc_version }}
fetch-depth: 0
path: embrace-apple-sdk
- name: Be sure Podspec has bumped version
run: |
cd embrace-apple-sdk
bin/version_bump $RC_VERSION --cocoapods
- name: Push EmbraceIO Podspec
run: |
pod trunk push embrace-apple-sdk/EmbraceIO.podspec --allow-warnings
# Note: missing/removed steps from old sdk
# - dsyms work