-
-
Notifications
You must be signed in to change notification settings - Fork 1
596 lines (529 loc) · 21.2 KB
/
release.yml
File metadata and controls
596 lines (529 loc) · 21.2 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
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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version tag (e.g., v0.1.0, v0.1.0-alpha.1)"
type: string
required: true
build_macos:
description: "Build macOS"
type: boolean
default: true
build_linux:
description: "Build Linux"
type: boolean
default: true
build_flatpak:
description: "Build Flatpak"
type: boolean
default: true
build_windows:
description: "Build Windows"
type: boolean
default: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
APP_NAME: trial-submission-studio
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
id-token: write
attestations: write
actions: read
jobs:
# ============================================================
# Prepare Release
# ============================================================
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
build_number: ${{ steps.version.outputs.BUILD_NUMBER }}
build_macos: ${{ inputs.build_macos }}
build_linux: ${{ inputs.build_linux }}
build_flatpak: ${{ inputs.build_flatpak }}
build_windows: ${{ inputs.build_windows }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate version
run: |
VERSION="${{ inputs.version }}"
# Check format
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Version must be in format v0.0.0 or v0.0.0-alpha.1"
exit 1
fi
echo "✓ Version format valid: $VERSION"
# Check if tag already exists locally
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "::error::Tag $VERSION already exists locally"
exit 1
fi
# Check if tag already exists on remote
if git ls-remote --tags origin | grep -q "refs/tags/$VERSION$"; then
echo "::error::Tag $VERSION already exists on remote"
exit 1
fi
echo "✓ Tag $VERSION is available"
- name: Create verified tag
id: version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ inputs.version }}"
COMMIT_COUNT=$(git rev-list --count HEAD)
BUILD_NUMBER="TSS-${{ github.run_number }}.${COMMIT_COUNT}"
SHA=$(git rev-parse HEAD)
# Create annotated tag via GitHub API (will be verified)
gh api repos/${{ github.repository }}/git/tags \
-f tag="$VERSION" \
-f message="Release $VERSION" \
-f object="$SHA" \
-f type="commit"
# Create tag reference
gh api repos/${{ github.repository }}/git/refs \
-f ref="refs/tags/$VERSION" \
-f sha="$SHA"
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_OUTPUT
echo "✓ Created verified tag: ${VERSION}"
# ============================================================
# macOS Builds
# ============================================================
build-macos:
name: macOS (${{ matrix.arch }})
needs: prepare
if: needs.prepare.outputs.build_macos == 'true'
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
runner: macos-latest
arch: arm64
- target: x86_64-apple-darwin
runner: macos-15-intel
arch: x86_64
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
env:
VERSION: ${{ needs.prepare.outputs.version }}
TARGET: ${{ matrix.target }}
TSS_BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.target }}
- name: Build
run: ./scripts/build-macos.sh
- name: Package
run: |
brew install create-dmg || true
SKIP_DMG=1 ./scripts/package-macos.sh
- name: Import certificate
env:
CERT_BASE64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
CERT_PASSWORD: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.CI_KEYCHAIN_PASSWORD }}
run: |
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security list-keychains -d user -s build.keychain login.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security set-keychain-settings -t 3600 -u build.keychain
echo "$CERT_BASE64" | base64 --decode > cert.p12
security import cert.p12 -k build.keychain -P "$CERT_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
rm cert.p12
- name: Sign app
env:
IDENTITY: ${{ secrets.APPLE_CODESIGN_IDENTITY }}
run: |
APP_BUNDLE="Trial Submission Studio.app"
MACOS_DIR="$APP_BUNDLE/Contents/MacOS"
HELPER_BUNDLE="$APP_BUNDLE/Contents/Helpers/tss-updater-helper.app"
ENTITLEMENTS="assets/macos/TrialSubmissionStudio.app/Contents/entitlements.plist"
# 1. Sign helper bundle FIRST (nested bundle must be signed before outer)
echo "Signing helper bundle: $HELPER_BUNDLE"
codesign --force --options runtime \
--entitlements "$ENTITLEMENTS" \
--sign "$IDENTITY" --timestamp "$HELPER_BUNDLE"
# 2. Verify helper is signed
echo "Verifying helper signature..."
codesign --verify --strict "$HELPER_BUNDLE"
# 3. Sign the main binary
echo "Signing main binary: $MACOS_DIR/trial-submission-studio"
codesign --force --options runtime \
--entitlements "$ENTITLEMENTS" \
--sign "$IDENTITY" --timestamp "$MACOS_DIR/trial-submission-studio"
# 4. Sign the main bundle (this seals everything including the signed helper)
echo "Signing bundle: $APP_BUNDLE"
codesign --force --options runtime \
--entitlements "$ENTITLEMENTS" \
--sign "$IDENTITY" --timestamp "$APP_BUNDLE"
# 5. Verify entire bundle with deep check
echo "Verifying entire bundle..."
codesign --verify --deep --strict "$APP_BUNDLE"
- name: Notarize
env:
APPLE_ID: ${{ secrets.APPLE_NOTARIZATION_APPLE_ID }}
APP_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_APP_PASSWORD }}
TEAM_ID: ${{ secrets.APPLE_DEVELOPER_TEAM_ID }}
run: |
ditto -c -k --keepParent "Trial Submission Studio.app" notarize.zip
xcrun notarytool submit notarize.zip --apple-id "$APPLE_ID" --password "$APP_PASSWORD" --team-id "$TEAM_ID" --wait --timeout 30m
xcrun stapler staple "Trial Submission Studio.app"
rm notarize.zip
- name: Create DMG from signed app
run: |
DMG_NAME="${APP_NAME}-${VERSION}-${{ matrix.target }}.dmg"
APP_DIR="Trial Submission Studio.app"
rm -f "$DMG_NAME"
create-dmg \
--volname "Trial Submission Studio" \
--volicon "assets/macos/TrialSubmissionStudio.app/Contents/Resources/AppIcon.icns" \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
--icon "${APP_DIR}" 150 190 \
--hide-extension "${APP_DIR}" \
--app-drop-link 450 190 \
"$DMG_NAME" \
"$APP_DIR"
- name: Sign DMG
env:
IDENTITY: ${{ secrets.APPLE_CODESIGN_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_NOTARIZATION_APPLE_ID }}
APP_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_APP_PASSWORD }}
TEAM_ID: ${{ secrets.APPLE_DEVELOPER_TEAM_ID }}
run: |
DMG_NAME="${APP_NAME}-${VERSION}-${{ matrix.target }}.dmg"
codesign --force --sign "$IDENTITY" --timestamp "$DMG_NAME"
xcrun notarytool submit "$DMG_NAME" --apple-id "$APPLE_ID" --password "$APP_PASSWORD" --team-id "$TEAM_ID" --wait --timeout 30m
xcrun stapler staple "$DMG_NAME"
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: macos-${{ matrix.arch }}
path: ${{ env.APP_NAME }}-${{ env.VERSION }}-${{ matrix.target }}.dmg
retention-days: 7
- name: Cleanup
if: always()
run: security delete-keychain build.keychain 2>/dev/null || true
# ============================================================
# Linux Builds
# ============================================================
build-linux:
name: Linux (${{ matrix.arch }})
needs: prepare
if: needs.prepare.outputs.build_linux == 'true'
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
arch: x86_64
- target: aarch64-unknown-linux-gnu
runner: ubuntu-24.04-arm
arch: arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
env:
VERSION: ${{ needs.prepare.outputs.version }}
TARGET: ${{ matrix.target }}
TSS_BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev libxdo-dev libfuse2
version: 1.1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.target }}
- name: Build
run: ./scripts/build-linux.sh
- name: Package
run: ./scripts/package-linux.sh
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: linux-${{ matrix.arch }}
path: |
${{ env.APP_NAME }}-${{ env.VERSION }}-${{ matrix.target }}.tar.gz
${{ env.APP_NAME }}-${{ env.VERSION }}-${{ matrix.target }}.AppImage
retention-days: 7
# ============================================================
# Flatpak Builds
# Uses flatpak-github-actions for building Flatpak bundles
# Docs: https://github.com/flatpak/flatpak-github-actions
# ============================================================
build-flatpak:
name: Flatpak (${{ matrix.config.arch }})
needs: prepare
if: needs.prepare.outputs.build_flatpak == 'true'
strategy:
fail-fast: false
matrix:
config:
# Native runners for each architecture (faster than QEMU emulation)
- arch: x86_64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.config.runner }}
container:
# Use Flathub infrastructure image matching runtime version (25.08)
# Available images: https://github.com/flathub-infra/actions-images
image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-25.08
options: --privileged
timeout-minutes: 90
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install flatpak-cargo-generator
run: |
pip install --quiet flatpak-cargo-generator
- name: Generate cargo sources
run: |
# Generate offline cargo sources from Cargo.lock
# This creates the vendored dependencies manifest
flatpak-cargo-generator Cargo.lock -o assets/flatpak/cargo-sources.json
echo "Generated cargo-sources.json with $(grep -c '"type":' assets/flatpak/cargo-sources.json || echo '?') entries"
- name: Update manifest git source
run: |
# Fix git ownership issue in container
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Get the commit hash for this version tag
COMMIT_HASH=$(git rev-parse HEAD)
# Update tag and commit in the manifest for reproducible builds
sed -i "s/tag: v.*/tag: ${{ env.VERSION }}/" assets/flatpak/io.github.rubentalstra.trial-submission-studio.yml
sed -i "s/commit: .*/commit: ${COMMIT_HASH}/" assets/flatpak/io.github.rubentalstra.trial-submission-studio.yml
echo "Updated manifest: tag=${{ env.VERSION }}, commit=${COMMIT_HASH}"
cat assets/flatpak/io.github.rubentalstra.trial-submission-studio.yml | grep -A2 "type: git"
- name: Build Flatpak
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
# Output bundle name
bundle: ${{ env.APP_NAME }}-${{ env.VERSION }}-${{ matrix.config.arch }}.flatpak
# Path to Flatpak manifest
manifest-path: assets/flatpak/io.github.rubentalstra.trial-submission-studio.yml
# Target architecture
arch: ${{ matrix.config.arch }}
# Cache key incorporates arch and content hashes for cache invalidation
cache-key: flatpak-builder-${{ matrix.config.arch }}-${{ hashFiles('Cargo.lock') }}
# Upload bundle as GitHub artifact
upload-artifact: true
# Enable verbose output for debugging build issues
verbose: true
- name: Lint manifest
run: |
flatpak-builder-lint \
--exceptions \
--gha-format \
manifest assets/flatpak/io.github.rubentalstra.trial-submission-studio.yml
- name: Lint appstream metadata
run: |
flatpak-builder-lint \
--exceptions \
--user-exceptions assets/flatpak/linter-exceptions.json \
--gha-format \
appstream flatpak_app/files/share/metainfo/io.github.rubentalstra.trial-submission-studio.metainfo.xml
- name: Lint build directory
run: |
flatpak-builder-lint \
--exceptions \
--user-exceptions assets/flatpak/linter-exceptions.json \
--gha-format \
builddir flatpak_app
- name: Lint repository
run: |
flatpak-builder-lint \
--exceptions \
--user-exceptions assets/flatpak/linter-exceptions.json \
--gha-format \
repo repo
- name: Save Flathub submission files
uses: actions/upload-artifact@v6
with:
name: flathub-${{ matrix.config.arch }}
path: |
assets/flatpak/io.github.rubentalstra.trial-submission-studio.yml
assets/flatpak/cargo-sources.json
retention-days: 7
# ============================================================
# Windows Builds
# ============================================================
build-windows:
name: Windows (${{ matrix.arch }})
needs: prepare
if: needs.prepare.outputs.build_windows == 'true'
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
runner: windows-latest
arch: x86_64
- target: aarch64-pc-windows-msvc
runner: windows-11-arm
arch: arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
env:
VERSION: ${{ needs.prepare.outputs.version }}
TARGET: ${{ matrix.target }}
TSS_BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.target }}
- name: Build
shell: bash
run: ./scripts/build-windows.sh
- name: Check signing
id: signing
shell: pwsh
env:
TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }}
run: |
if ($env:TOKEN) { "available=true" >> $env:GITHUB_OUTPUT }
else { "available=false" >> $env:GITHUB_OUTPUT }
- name: Sign (if available)
if: steps.signing.outputs.available == 'true'
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ secrets.SIGNPATH_ORGANIZATION_ID }}
project-slug: ${{ secrets.SIGNPATH_PROJECT_SLUG }}
signing-policy-slug: ${{ secrets.SIGNPATH_SIGNING_POLICY_SLUG }}
artifact-configuration-slug: release-signing
github-artifact-id: ${{ github.run_id }}
wait-for-completion: true
- name: Package
shell: pwsh
run: |
$binary = "target/${{ matrix.target }}/release/$env:APP_NAME.exe"
$zipName = "$env:APP_NAME-$env:VERSION-${{ matrix.target }}.zip"
$exeName = "$env:APP_NAME-$env:VERSION-${{ matrix.target }}.exe"
Compress-Archive -Path $binary -DestinationPath $zipName
Copy-Item $binary $exeName
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: windows-${{ matrix.arch }}
path: |
${{ env.APP_NAME }}-${{ env.VERSION }}-${{ matrix.target }}.zip
${{ env.APP_NAME }}-${{ env.VERSION }}-${{ matrix.target }}.exe
retention-days: 7
# ============================================================
# Publish Release
# ============================================================
publish:
name: Publish
needs: [ prepare, build-macos, build-linux, build-flatpak, build-windows ]
if: |
always() &&
(needs.build-macos.result == 'success' || needs.build-macos.result == 'skipped') &&
(needs.build-linux.result == 'success' || needs.build-linux.result == 'skipped') &&
(needs.build-flatpak.result == 'success' || needs.build-flatpak.result == 'skipped') &&
(needs.build-windows.result == 'success' || needs.build-windows.result == 'skipped') &&
(needs.build-macos.result == 'success' || needs.build-linux.result == 'success' || needs.build-flatpak.result == 'success' || needs.build-windows.result == 'success')
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Download artifacts (excluding Flathub files)
uses: actions/download-artifact@v7
with:
path: artifacts
merge-multiple: true
- name: Remove Flathub submission files
run: rm -rf artifacts/flathub-*
- name: List artifacts
run: find artifacts -type f -exec ls -lh {} \; 2>/dev/null || ls -la artifacts/
- name: Generate attestations
uses: actions/attest-build-provenance@v2
with:
subject-path: "artifacts/*"
- name: Determine prerelease
id: prerelease
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
if [[ "$VERSION" == *"-alpha"* ]] || [[ "$VERSION" == *"-beta"* ]] || [[ "$VERSION" == *"-rc"* ]]; then
echo "PRERELEASE=true" >> $GITHUB_OUTPUT
else
echo "PRERELEASE=false" >> $GITHUB_OUTPUT
fi
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.version }}
name: "${{ needs.prepare.outputs.version }}"
draft: false
prerelease: ${{ steps.prerelease.outputs.PRERELEASE }}
generate_release_notes: true
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ============================================================
# Notify Flathub (Post-Approval Only)
# ============================================================
# This job is disabled until after your app is approved on Flathub.
# Once flathub/io.github.rubentalstra.trial-submission-studio exists,
# set FLATHUB_TOKEN secret to enable automatic update notifications.
notify-flathub:
name: Notify Flathub
needs: [ prepare, publish ]
if: |
false &&
needs.publish.result == 'success' &&
!contains(needs.prepare.outputs.version, '-alpha') &&
!contains(needs.prepare.outputs.version, '-beta')
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Trigger Flathub update
env:
FLATHUB_TOKEN: ${{ secrets.FLATHUB_TOKEN }}
run: |
if [[ -z "$FLATHUB_TOKEN" ]]; then
echo "::warning::FLATHUB_TOKEN not set. Skipping Flathub notification."
exit 0
fi
gh api repos/flathub/io.github.rubentalstra.trial-submission-studio/dispatches \
-f event_type="new-release" \
-f client_payload='{"version": "${{ needs.prepare.outputs.version }}"}'