-
Notifications
You must be signed in to change notification settings - Fork 0
460 lines (401 loc) · 19 KB
/
release.yml
File metadata and controls
460 lines (401 loc) · 19 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
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
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # Required to create releases
actions: read # Required to download artifacts from other workflows
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python (release gates)
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Sync version from git tag
run: python scripts/sync_version.py --tag ${{ github.ref_name }}
- name: Validate version
run: python scripts/validate_version.py
- name: Validate changelog
run: python scripts/validate_changelog.py
- name: Wait for build workflows to complete
run: |
TAG="${{ github.ref }}"
REPO="${{ github.repository }}"
echo "Waiting for build workflows to complete for tag: ${TAG}"
# Extract tag name (remove refs/tags/ prefix)
TAG_NAME="${TAG#refs/tags/}"
# Install jq for JSON parsing (more reliable than grep)
sudo apt-get update && sudo apt-get install -y jq
# Wait for both macOS and Windows build workflows to complete
MAX_WAIT=3600 # 60 minutes max
WAIT_INTERVAL=30 # Check every 30 seconds
ELAPSED=0
while [ $ELAPSED -lt $MAX_WAIT ]; do
echo "Checking workflow status (elapsed: ${ELAPSED}s)..."
# Check macOS workflow using GitHub API
# For tags, we need to search by ref (tag name) not head_branch
MACOS_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${REPO}/actions/workflows/build-macos.yml/runs?ref=${TAG_NAME}&per_page=1")
# Extract conclusion using jq (more reliable)
MACOS_STATUS=$(echo "$MACOS_RESPONSE" | jq -r '.workflow_runs[0].conclusion // .workflow_runs[0].status // "unknown"' 2>/dev/null || echo "unknown")
# Normalize status values
if [ "$MACOS_STATUS" = "in_progress" ] || [ "$MACOS_STATUS" = "queued" ]; then
MACOS_STATUS="running"
fi
# Check Windows workflow using GitHub API
WINDOWS_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${REPO}/actions/workflows/build-windows.yml/runs?ref=${TAG_NAME}&per_page=1")
# Extract conclusion using jq (more reliable)
WINDOWS_STATUS=$(echo "$WINDOWS_RESPONSE" | jq -r '.workflow_runs[0].conclusion // .workflow_runs[0].status // "unknown"' 2>/dev/null || echo "unknown")
# Normalize status values
if [ "$WINDOWS_STATUS" = "in_progress" ] || [ "$WINDOWS_STATUS" = "queued" ]; then
WINDOWS_STATUS="running"
fi
echo "macOS build status: ${MACOS_STATUS}"
echo "Windows build status: ${WINDOWS_STATUS}"
# Debug: show API response if status is unknown or empty
if [ "$MACOS_STATUS" = "unknown" ] || [ "$WINDOWS_STATUS" = "unknown" ] || [ -z "$MACOS_STATUS" ] || [ -z "$WINDOWS_STATUS" ]; then
echo "Debug - macOS API response (first 500 chars):"
echo "$MACOS_RESPONSE" | head -c 500
echo ""
echo "Debug - Windows API response (first 500 chars):"
echo "$WINDOWS_RESPONSE" | head -c 500
echo ""
fi
if [ "${MACOS_STATUS}" = "success" ] && [ "${WINDOWS_STATUS}" = "success" ]; then
echo "Both build workflows completed successfully!"
exit 0
fi
if [ "${MACOS_STATUS}" = "failure" ] || [ "${WINDOWS_STATUS}" = "failure" ]; then
echo "One or more build workflows failed!"
exit 1
fi
# If workflows are still running or not found, wait and retry
if [ "${MACOS_STATUS}" = "running" ] || [ "${WINDOWS_STATUS}" = "running" ] || [ "${MACOS_STATUS}" = "null" ] || [ "${WINDOWS_STATUS}" = "null" ]; then
echo "Workflows still running or not found, waiting..."
fi
sleep $WAIT_INTERVAL
ELAPSED=$((ELAPSED + WAIT_INTERVAL))
done
echo "Timeout waiting for build workflows to complete"
exit 1
- name: Download macOS artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: build-macos.yml
name: macos-dmg
path: artifacts/macos
github_token: ${{ secrets.GITHUB_TOKEN }}
if_no_artifact_found: fail
commit: ${{ github.sha }}
workflow_conclusion: success
allow_forks: false
- name: Download Windows artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: build-windows.yml
name: windows-installer
path: artifacts/windows
github_token: ${{ secrets.GITHUB_TOKEN }}
if_no_artifact_found: fail
commit: ${{ github.sha }}
workflow_conclusion: success
allow_forks: false
- name: Create Windows README
run: |
printf '%s\n' \
'CuePoint - Installation (unsigned app)' \
'' \
'Step 1: Open CuePoint Setup.exe' \
'' \
'Step 2: After you get a popup called "Windows protected your PC", click "More info"' \
'' \
'Step 3: Click "Run anyway" (this happens because we do not pay 200 euros/year to sign the app with Microsoft)' \
'' \
'Step 4: Install and enjoy' \
> artifacts/windows/README.txt
echo "Created artifacts/windows/README.txt"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Generate THIRD_PARTY_LICENSES.txt for release
run: |
pip install -r requirements-build.txt -q
python scripts/generate_licenses.py --output THIRD_PARTY_LICENSES.txt
if [ ! -f THIRD_PARTY_LICENSES.txt ]; then
echo "ERROR: License bundle generation failed"
exit 1
fi
- name: Generate SBOM
run: |
mkdir -p dist
python scripts/generate_sbom.py --output dist/sbom.spdx.json
- name: Generate checksums
run: |
python scripts/generate_checksums.py \
--artifacts $(ls artifacts/macos/*.dmg artifacts/windows/*.exe 2>/dev/null) \
--output SHA256SUMS \
--algorithms sha256
- name: Sign checksum file (optional, design 2.17)
id: sign_checksums
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
if [ -z "$GPG_PRIVATE_KEY" ]; then
echo "No GPG_PRIVATE_KEY secret; skipping checksum signing."
exit 0
fi
echo "Configuring GPG for headless CI..."
mkdir -p ~/.gnupg
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
chmod 600 ~/.gnupg/gpg-agent.conf
echo "Importing GPG key..."
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
echo "Signing SHA256SUMS..."
if [ -n "$GPG_PASSPHRASE" ]; then
python scripts/sign_checksums.py SHA256SUMS --passphrase
else
python scripts/sign_checksums.py SHA256SUMS
fi
if [ -f SHA256SUMS.asc ]; then
echo "Signed: SHA256SUMS.asc"
fi
- name: Sync version from git tag
run: |
echo "Syncing version.py from git tag: ${{ github.ref_name }}"
python scripts/sync_version.py --tag ${{ github.ref_name }}
if [ $? -ne 0 ]; then
echo "Error: Version sync failed"
exit 1
fi
echo "[OK] Version synced successfully"
- name: Generate release notes (from PRs, design 2.18)
run: python scripts/generate_release_notes.py --tag ${{ github.ref_name }} --output RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
# All tags create a published release. Test tags (e.g. v1.0.3-test1.1) are
# marked prerelease so assets are public (no 404); website uses releases/latest
# which returns only non-prerelease, so it points to stable only.
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/macos/*.dmg
artifacts/windows/*.exe
artifacts/windows/README.txt
dist/sbom.spdx.json
THIRD_PARTY_LICENSES.txt
SHA256SUMS
body_path: RELEASE_NOTES.md
draft: false
prerelease: ${{ contains(github.ref_name, '-test') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload checksum signature (if GPG signed)
if: hashFiles('SHA256SUMS.asc') != ''
run: gh release upload ${{ github.ref_name }} SHA256SUMS.asc --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# --- Test tag only: fetch existing test appcasts from gh-pages (design: two appcast feeds) ---
- name: Fetch Existing Test Appcast Feeds
if: ${{ contains(github.ref_name, '-test') }}
run: |
echo "=== Fetching Existing Test Appcast Feeds ==="
mkdir -p updates/macos/test
mkdir -p updates/windows/test
git fetch origin gh-pages:gh-pages 2>/dev/null || echo "gh-pages branch not found, will create new test appcasts"
if git show origin/gh-pages:updates/macos/test/appcast.xml > updates/macos/test/appcast.xml 2>/dev/null; then
echo "[OK] Fetched existing macOS test appcast"
else
echo "[INFO] No existing macOS test appcast found, will create new one"
rm -f updates/macos/test/appcast.xml
fi
if git show origin/gh-pages:updates/windows/test/appcast.xml > updates/windows/test/appcast.xml 2>/dev/null; then
echo "[OK] Fetched existing Windows test appcast"
else
echo "[INFO] No existing Windows test appcast found, will create new one"
rm -f updates/windows/test/appcast.xml
fi
- name: Generate Test Appcast Feeds
if: ${{ contains(github.ref_name, '-test') }}
run: |
echo "=== Generating Test Appcast Feeds ==="
VERSION="${{ github.ref_name }}"
REPO="${{ github.repository }}"
VERSION_NUM="${VERSION#v}"
echo "Version: $VERSION_NUM"
DMG_FILE=$(ls artifacts/macos/*.dmg 2>/dev/null | head -1)
EXE_FILE=$(ls artifacts/windows/*.exe 2>/dev/null | head -1)
if [ -z "$DMG_FILE" ] || [ -z "$EXE_FILE" ]; then
echo "Warning: DMG or EXE file not found, skipping test appcast generation"
exit 0
fi
DMG_URL="https://github.com/$REPO/releases/download/$VERSION/$(basename $DMG_FILE)"
EXE_URL="https://github.com/$REPO/releases/download/$VERSION/$(basename $EXE_FILE)"
RELEASE_NOTES_URL="https://github.com/$REPO/releases/tag/$VERSION"
if [ -f "$DMG_FILE" ]; then
python scripts/generate_appcast.py \
--dmg "$DMG_FILE" \
--version "$VERSION_NUM" \
--url "$DMG_URL" \
--notes "$RELEASE_NOTES_URL" \
--output updates/macos/test/appcast.xml \
--append \
--channel test
echo "[OK] macOS test appcast generated"
fi
if [ -f "$EXE_FILE" ]; then
python scripts/generate_update_feed.py \
--exe "$EXE_FILE" \
--version "$VERSION_NUM" \
--url "$EXE_URL" \
--notes "$RELEASE_NOTES_URL" \
--output updates/windows/test/appcast.xml \
--append \
--channel test
echo "[OK] Windows test appcast generated"
fi
echo "Test appcast generation complete"
- name: Validate Test Appcast Feeds
if: ${{ contains(github.ref_name, '-test') }}
run: |
echo "=== Validating Test Appcast Feeds ==="
if [ -f "updates/macos/test/appcast.xml" ] && [ -f "updates/windows/test/appcast.xml" ]; then
python scripts/validate_feeds.py \
--macos updates/macos/test/appcast.xml \
--windows updates/windows/test/appcast.xml
echo "[OK] Test appcast feeds validated"
else
echo "Warning: Test appcast files not found, skipping validation"
fi
- name: Publish Test Appcast Feeds to GitHub Pages
if: ${{ contains(github.ref_name, '-test') }}
run: |
echo "=== Publishing Test Appcast Feeds (no index) ==="
if [ -f "updates/macos/test/appcast.xml" ] && [ -f "updates/windows/test/appcast.xml" ]; then
python scripts/publish_feeds.py \
updates/macos/test/appcast.xml updates/windows/test/appcast.xml \
--branch gh-pages \
--message "Update appcast feeds (test) for ${{ github.ref_name }}" \
--github-token "${{ secrets.GITHUB_TOKEN }}"
echo "[OK] Test appcast feeds published to gh-pages branch"
else
echo "Warning: Test appcast files not found, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch Existing Appcast Feeds
if: ${{ !contains(github.ref_name, '-test') }}
run: |
echo "=== Fetching Existing Appcast Feeds ==="
# Create updates directory structure
mkdir -p updates/macos/stable
mkdir -p updates/windows/stable
# Try to fetch existing appcast files from gh-pages branch
# This allows --append to work correctly
git fetch origin gh-pages:gh-pages 2>/dev/null || echo "gh-pages branch not found, will create new appcasts"
# Checkout existing appcast files if they exist
if git show origin/gh-pages:updates/macos/stable/appcast.xml > updates/macos/stable/appcast.xml 2>/dev/null; then
echo "[OK] Fetched existing macOS appcast"
else
echo "[INFO] No existing macOS appcast found, will create new one"
rm -f updates/macos/stable/appcast.xml
fi
if git show origin/gh-pages:updates/windows/stable/appcast.xml > updates/windows/stable/appcast.xml 2>/dev/null; then
echo "[OK] Fetched existing Windows appcast"
else
echo "[INFO] No existing Windows appcast found, will create new one"
rm -f updates/windows/stable/appcast.xml
fi
- name: Generate Appcast Feeds
if: ${{ !contains(github.ref_name, '-test') }}
run: |
echo "=== Generating Appcast Feeds ==="
VERSION="${{ github.ref_name }}"
REPO="${{ github.repository }}"
# Extract version without 'v' prefix if present
VERSION_NUM="${VERSION#v}"
echo "Version: $VERSION_NUM"
echo "Repository: $REPO"
# Find DMG and EXE files
DMG_FILE=$(ls artifacts/macos/*.dmg 2>/dev/null | head -1)
EXE_FILE=$(ls artifacts/windows/*.exe 2>/dev/null | head -1)
if [ -z "$DMG_FILE" ] || [ -z "$EXE_FILE" ]; then
echo "Warning: DMG or EXE file not found, skipping appcast generation"
echo " DMG: $DMG_FILE"
echo " EXE: $EXE_FILE"
exit 0
fi
echo "DMG file: $DMG_FILE"
echo "EXE file: $EXE_FILE"
# Generate download URLs
DMG_URL="https://github.com/$REPO/releases/download/$VERSION/$(basename $DMG_FILE)"
EXE_URL="https://github.com/$REPO/releases/download/$VERSION/$(basename $EXE_FILE)"
RELEASE_NOTES_URL="https://github.com/$REPO/releases/tag/$VERSION"
echo "DMG URL: $DMG_URL"
echo "EXE URL: $EXE_URL"
# Generate macOS appcast (with --append to merge with existing)
if [ -f "$DMG_FILE" ]; then
echo "Generating macOS appcast..."
python scripts/generate_appcast.py \
--dmg "$DMG_FILE" \
--version "$VERSION_NUM" \
--url "$DMG_URL" \
--notes "$RELEASE_NOTES_URL" \
--output updates/macos/stable/appcast.xml \
--append \
--channel stable
echo "[OK] macOS appcast generated"
fi
# Generate Windows appcast (with --append to merge with existing)
if [ -f "$EXE_FILE" ]; then
echo "Generating Windows appcast..."
python scripts/generate_update_feed.py \
--exe "$EXE_FILE" \
--version "$VERSION_NUM" \
--url "$EXE_URL" \
--notes "$RELEASE_NOTES_URL" \
--output updates/windows/stable/appcast.xml \
--append \
--channel stable
echo "[OK] Windows appcast generated"
fi
echo "Appcast generation complete"
- name: Validate Appcast Feeds
if: ${{ !contains(github.ref_name, '-test') }}
run: |
echo "=== Validating Appcast Feeds ==="
if [ -f "updates/macos/stable/appcast.xml" ] && [ -f "updates/windows/stable/appcast.xml" ]; then
python scripts/validate_feeds.py \
--macos updates/macos/stable/appcast.xml \
--windows updates/windows/stable/appcast.xml
echo "[OK] Appcast feeds validated"
else
echo "Warning: Appcast files not found, skipping validation"
fi
- name: Publish Appcast Feeds to GitHub Pages
if: ${{ !contains(github.ref_name, '-test') }}
run: |
echo "=== Publishing Appcast Feeds ==="
# Use publish_feeds.py script for reliable publishing
if [ -f "updates/macos/stable/appcast.xml" ] && [ -f "updates/windows/stable/appcast.xml" ]; then
python scripts/publish_feeds.py \
updates/macos/stable/appcast.xml updates/windows/stable/appcast.xml \
--branch gh-pages \
--message "Update appcast feeds for ${{ github.ref_name }}" \
--github-token "${{ secrets.GITHUB_TOKEN }}" \
--index gh-pages-root/index.html
echo "[OK] Appcast feeds published to gh-pages branch"
else
echo "Warning: Appcast files not found, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}