-
Notifications
You must be signed in to change notification settings - Fork 29
302 lines (252 loc) · 9.48 KB
/
Copy pathrelease.yml
File metadata and controls
302 lines (252 loc) · 9.48 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
name: Release
on:
push:
branches:
- 'release/*'
tags:
- 'v*'
permissions:
contents: write
jobs:
# ============================================================================
# RELEASE CANDIDATE BUILD - Triggered on release/* branches
# ============================================================================
rc-test:
name: RC - Test & Validate
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: macos-26
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_CLEANUP: "1"
steps:
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_26.2.app
- name: Cache Mint packages
uses: actions/cache@v4
with:
path: ~/.mint
key: ${{ runner.os }}-mint-${{ hashFiles('Mintfile') }}
restore-keys: ${{ runner.os }}-mint-
- name: Cache Homebrew downloads
uses: actions/cache@v4
with:
path: ~/Library/Caches/Homebrew
key: ${{ runner.os }}-homebrew-${{ hashFiles('.github/workflows/release.yml') }}
restore-keys: ${{ runner.os }}-homebrew-
- name: Install Mint
run: brew install mint
- name: Install SwiftLint and Periphery
run: mint bootstrap
- name: Lint
run: mint run swiftlint lint --strict
- name: Build
run: swift build --build-tests --enable-all-traits
- name: Test
run: swift test --enable-all-traits
- name: Periphery
run: mint run periphery scan
rc-test-linux:
name: RC - Test (Linux)
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
needs: rc-test
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build --enable-all-traits 2>&1
- name: Test
run: swift test --enable-all-traits 2>&1
rc-build-xcframework:
name: RC - Build XCFramework
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: macos-26
needs: rc-test
strategy:
matrix:
framework: [SwiftRex, SwiftRexOperators, SwiftRexSwiftConcurrency, SwiftRexCombine, SwiftRexSwiftUI]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_26.2.app
- name: Resolve Package Dependencies
run: swift package resolve
- name: Build Library in Release Configuration
run: |
set -x
swift build -c release --target ${{ matrix.framework }} -v
echo "✓ Build succeeded"
- name: Create XCFramework Structure
run: |
XCFWK_PATH="build/${{ matrix.framework }}/${{ matrix.framework }}.xcframework"
mkdir -p "$XCFWK_PATH"
# Copy Swift module files
for ext in swiftmodule swiftdoc abi.json swiftsourceinfo; do
if [ -f ".build/release/Modules/${{ matrix.framework }}.$ext" ]; then
cp ".build/release/Modules/${{ matrix.framework }}.$ext" "$XCFWK_PATH/"
echo "✓ Copied ${{ matrix.framework }}.$ext"
fi
done
echo "✓ XCFramework structure created"
- name: Verify XCFramework Created
run: |
XCFWK_PATH="build/${{ matrix.framework }}/${{ matrix.framework }}.xcframework"
if [ -d "$XCFWK_PATH" ]; then
echo "✓ XCFramework structure created"
ls -lah "$XCFWK_PATH"
find "$XCFWK_PATH" -type f
else
echo "✗ XCFramework not found"
find build -type d -o -type f | head -50
exit 1
fi
- name: Archive XCFramework
run: |
cd build/${{ matrix.framework }}
zip -r ${{ matrix.framework }}.xcframework.zip ${{ matrix.framework }}.xcframework
cd ../..
ls -lh build/${{ matrix.framework }}/${{ matrix.framework }}.xcframework.zip
- name: Upload XCFramework Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.framework }}-xcframework
path: build/${{ matrix.framework }}/${{ matrix.framework }}.xcframework.zip
retention-days: 90
rc-notify-status:
name: RC - Notify Status
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
needs: [rc-test, rc-test-linux, rc-build-xcframework]
steps:
- name: Extract Version
id: version
run: |
BRANCH="${{ github.ref_name }}"
VERSION=${BRANCH#release/}
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Success Notification
if: success()
run: |
echo "::notice::Release Candidate ${{ steps.version.outputs.version }} is ready for promotion"
echo ""
echo "Next steps:"
echo "1. Verify the XCFramework artifacts above"
echo "2. When ready, run the 'Promote RC to Release' workflow"
- name: Failure Notification
if: failure()
run: |
echo "::error::Release Candidate build failed"
echo "Push fixes to: ${{ github.ref_name }}"
# ============================================================================
# RELEASE PROMOTION - Triggered on version tags (v*.*.*)
# ============================================================================
promote-test:
name: Promote - Verify Tag
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate Tag Format
run: |
TAG="${{ github.ref_name }}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Invalid tag format: $TAG"
exit 1
fi
echo "::notice::Promoting tag: $TAG"
- name: Verify Tag on Release Branch
run: |
TAG="${{ github.ref_name }}"
VERSION=${TAG#v}
if git show-ref --verify --quiet "refs/remotes/origin/release/$VERSION"; then
echo "::notice::Found corresponding release branch: release/$VERSION"
else
echo "::warning::No release branch found for release/$VERSION"
echo "It's OK to proceed if the tag is on main branch"
fi
create-release:
name: Promote - Create Release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: macos-26
needs: promote-test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download RC Artifacts
run: |
TAG="${{ github.ref_name }}"
VERSION=${TAG#v}
BRANCH="release/$VERSION"
RUN_ID=$(gh api "repos/${{ github.repository }}/actions/runs?branch=${BRANCH}&status=success&per_page=20" \
--jq '[.workflow_runs[] | select(.name == "Release")] | first | .id')
if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "null" ]; then
echo "::error::No successful RC build found for branch $BRANCH"
exit 1
fi
echo "::notice::Downloading artifacts from run $RUN_ID (branch: $BRANCH)"
mkdir -p artifacts
gh run download "$RUN_ID" --dir artifacts
env:
GH_TOKEN: ${{ github.token }}
- name: Generate Release Notes
id: notes
run: |
TAG="${{ github.ref_name }}"
VERSION=${TAG#v}
PREV_TAG=$(git describe --tags --abbrev=0 ${TAG}^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
BODY="Initial release"
else
COMMITS=$(git log ${PREV_TAG}..${TAG} --oneline)
BODY="## Changes
${COMMITS}
## Installation
### Swift Package Manager
\`\`\`swift
.package(url: \"https://github.com/SwiftRex/SwiftRex.git\", from: \"${VERSION}\")
\`\`\`
### XCFrameworks
See the attached \`.xcframework.zip\` files for pre-built binaries of the
dependency-free products (SwiftRex, SwiftRexOperators, SwiftRexSwiftConcurrency,
SwiftRexCombine, SwiftRexSwiftUI). The RxSwift, ReactiveSwift, and
ReactiveConcurrency bridges are available via SPM only."
fi
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: List Artifacts
run: |
echo "Found artifacts:"
find artifacts -name "*.zip" -exec ls -lh {} \;
- name: Create Release
run: |
gh release create "${{ github.ref_name }}" \
--title "Release ${{ github.ref_name }}" \
--notes "${{ steps.notes.outputs.body }}" \
artifacts/*/*.zip
env:
GH_TOKEN: ${{ github.token }}
notify-promotion-status:
name: Promote - Notify Status
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [promote-test, create-release]
steps:
- name: Success Notification
if: success()
run: |
echo "::notice::Release ${{ github.ref_name }} published successfully"
echo "View release: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}"
- name: Failure Notification
if: failure()
run: |
echo "::error::Release promotion failed for tag ${{ github.ref_name }}"
echo ""
echo "Recovery:"
echo "1. Delete the tag: git tag -d ${{ github.ref_name }} && git push origin :refs/tags/${{ github.ref_name }}"
echo "2. Fix issues, then retry"