Open History to see the last commit
1name: Release
2
3on:
4 push:
5 tags:
6 - "v*.*.*"
7 schedule:
8 - cron: "0 */3 * * *"
9 workflow_dispatch:
10 inputs:
11 channel:
12 description: "Release channel"
13 required: false
14 default: stable
15 type: choice
16 options:
17 - stable
18 - nightly
19 version:
20 description: "Release version (for example 1.2.3 or v1.2.3)"
21 required: false
22 type: string
23
24permissions:
25 contents: write
26 id-token: write
27
28jobs:
29 check_changes:
30 name: Check for changes since last nightly
31 if: github.event_name == 'schedule'
32 runs-on: ubuntu-24.04
33 outputs:
34 has_changes: ${{ steps.check.outputs.has_changes }}
35 steps:
36 - name: Checkout
37 uses: actions/checkout@v6
38 with:
39 fetch-depth: 0
40
41 - id: check
42 name: Compare HEAD to last nightly tag
43 run: |
44 last_nightly_tag=$(git tag --list 'nightly-v*' --sort=-creatordate | head -n 1)
45 if [[ -z "$last_nightly_tag" ]]; then
46 echo "No previous nightly tag found. Proceeding with release."
47 echo "has_changes=true" >> "$GITHUB_OUTPUT"
48 exit 0
49 fi
50
51 last_nightly_sha=$(git rev-parse "$last_nightly_tag^{commit}")
52 head_sha=$(git rev-parse HEAD)
53
54 if [[ "$last_nightly_sha" == "$head_sha" ]]; then
55 echo "No changes on main since last nightly release ($last_nightly_tag). Skipping."
56 echo "has_changes=false" >> "$GITHUB_OUTPUT"
57 else
58 echo "Changes detected on main since $last_nightly_tag ($last_nightly_sha → $head_sha). Proceeding."
59 echo "has_changes=true" >> "$GITHUB_OUTPUT"
60 fi
61
62 preflight:
63 name: Preflight
64 needs: [check_changes]
65 if: |
66 !failure() && !cancelled() &&
67 (github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
68 runs-on: blacksmith-8vcpu-ubuntu-2404
69 timeout-minutes: 10
70 outputs:
71 release_channel: ${{ steps.release_meta.outputs.release_channel }}
72 version: ${{ steps.release_meta.outputs.version }}
73 tag: ${{ steps.release_meta.outputs.tag }}
74 release_name: ${{ steps.release_meta.outputs.name }}
75 short_sha: ${{ steps.release_meta.outputs.short_sha }}
76 previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
77 cli_dist_tag: ${{ steps.release_meta.outputs.cli_dist_tag }}
78 is_prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
79 make_latest: ${{ steps.release_meta.outputs.make_latest }}
80 ref: ${{ github.sha }}
81 steps:
82 - name: Checkout
83 uses: actions/checkout@v6
84 with:
85 fetch-depth: 0
86
87 - name: Setup Bun
88 uses: oven-sh/setup-bun@v2
89 with:
90 bun-version-file: package.json
91
92 - name: Setup Node
93 uses: actions/setup-node@v6
94 with:
95 node-version-file: package.json
96
97 - name: Install dependencies
98 run: bun install --frozen-lockfile
99
100 - id: release_meta
101 name: Resolve release version
102 shell: bash
103 env:
104 DISPATCH_CHANNEL: ${{ github.event.inputs.channel }}
105 DISPATCH_VERSION: ${{ github.event.inputs.version }}
106 NIGHTLY_DATE: ${{ github.run_started_at }}
107 NIGHTLY_SHA: ${{ github.sha }}
108 NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
109 run: |
110 if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "nightly" ) ]]; then
111 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
112
113 node scripts/resolve-nightly-release.ts \
114 --date "$nightly_date" \
115 --run-number "$NIGHTLY_RUN_NUMBER" \
116 --sha "$NIGHTLY_SHA" \
117 --github-output
118
119 echo "release_channel=nightly" >> "$GITHUB_OUTPUT"
120 echo "cli_dist_tag=nightly" >> "$GITHUB_OUTPUT"
121 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
122 echo "make_latest=false" >> "$GITHUB_OUTPUT"
123 else
124 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
125 raw="${DISPATCH_VERSION}"
126 if [[ -z "$raw" ]]; then
127 echo "workflow_dispatch stable releases require the version input." >&2
128 exit 1
129 fi
130 else
131 raw="${GITHUB_REF_NAME}"
132 fi
133
134 version="${raw#v}"
135 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
136 echo "Invalid release version: $raw" >&2
137 exit 1
138 fi
139
140 echo "release_channel=stable" >> "$GITHUB_OUTPUT"
141 echo "version=$version" >> "$GITHUB_OUTPUT"
142 echo "tag=v$version" >> "$GITHUB_OUTPUT"
143 echo "name=T3 Code v$version" >> "$GITHUB_OUTPUT"
144 echo "cli_dist_tag=latest" >> "$GITHUB_OUTPUT"
145 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
146 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
147 echo "make_latest=true" >> "$GITHUB_OUTPUT"
148 else
149 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
150 echo "make_latest=false" >> "$GITHUB_OUTPUT"
151 fi
152 fi
153
154 - name: Lint
155 run: bun run lint
156
157 - name: Typecheck
158 run: bun run typecheck
159
160 - name: Test
161 run: bun run test
162
163 - id: previous_tag
164 name: Resolve previous release tag
165 run: |
166 node scripts/resolve-previous-release-tag.ts \
167 --channel "${{ steps.release_meta.outputs.release_channel }}" \
168 --current-tag "${{ steps.release_meta.outputs.tag }}" \
169 --github-output
170
171 build:
172 name: Build ${{ matrix.label }}
173 needs: preflight
174 runs-on: ${{ matrix.runner }}
175 timeout-minutes: 30
176 strategy:
177 fail-fast: false
178 matrix:
179 include:
180 - label: macOS arm64
181 runner: blacksmith-12vcpu-macos-26
182 platform: mac
183 target: dmg
184 arch: arm64
185 - label: macOS x64
186 runner: blacksmith-12vcpu-macos-26
187 platform: mac
188 target: dmg
189 arch: x64
190 - label: Linux x64
191 runner: blacksmith-32vcpu-ubuntu-2404
192 platform: linux
193 target: AppImage
194 arch: x64
195 - label: Windows x64
196 runner: blacksmith-32vcpu-windows-2025
197 platform: win
198 target: nsis
199 arch: x64
200 # - label: Windows arm64
201 # runner: windows-11-arm
202 # platform: win
203 # target: nsis
204 # arch: arm64
205 steps:
206 - name: Checkout
207 uses: actions/checkout@v6
208 with:
209 ref: ${{ needs.preflight.outputs.ref }}
210 fetch-depth: 0
211
212 - name: Setup Bun
213 uses: oven-sh/setup-bun@v2
214 with:
215 bun-version-file: package.json
216
217 - name: Setup Node
218 uses: actions/setup-node@v6
219 with:
220 node-version-file: package.json
221
222 - name: Install dependencies
223 run: bun install --frozen-lockfile
224
225 - name: Align package versions to release version
226 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
227
228 - name: Install Spectre-mitigated MSVC libs
229 if: matrix.platform == 'win'
230 shell: pwsh
231 run: |
232 $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
233 $installPath = & $vswhere -products * -latest -property installationPath
234 $setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
235 $proc = Start-Process -FilePath $setupExe `
236 -ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
237 "Microsoft.VisualStudio.Component.VC.Tools.x86.x64.Spectre", "--quiet", "--norestart" `
238 -Wait -PassThru -NoNewWindow
239 if ($null -eq $proc -or $proc.ExitCode -ne 0) {
240 $code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
241 Write-Error "Visual Studio Installer failed with exit code $code"
242 exit $code
243 }
244
245 - name: Build desktop artifact
246 shell: bash
247 env:
248 CSC_LINK: ${{ secrets.CSC_LINK }}
249 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
250 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
251 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
252 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
253 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
254 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
255 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
256 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
257 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
258 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
259 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
260 run: |
261 args=(
262 --platform "${{ matrix.platform }}"
263 --target "${{ matrix.target }}"
264 --arch "${{ matrix.arch }}"
265 --build-version "${{ needs.preflight.outputs.version }}"
266 --verbose
267 )
268
269 has_all() {
270 for value in "$@"; do
271 if [[ -z "$value" ]]; then
272 return 1
273 fi
274 done
275 return 0
276 }
277
278 if [[ "${{ matrix.platform }}" == "mac" ]]; then
279 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
280 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
281 printf '%s' "$APPLE_API_KEY" > "$key_path"
282 export APPLE_API_KEY="$key_path"
283 echo "macOS signing enabled."
284 args+=(--signed)
285 else
286 echo "macOS signing disabled (missing one or more Apple signing secrets)."
287 fi
288 elif [[ "${{ matrix.platform }}" == "win" ]]; then
289 if has_all \
290 "$AZURE_TENANT_ID" \
291 "$AZURE_CLIENT_ID" \
292 "$AZURE_CLIENT_SECRET" \
293 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
294 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
295 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
296 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
297 echo "Windows signing enabled (Azure Trusted Signing)."
298 args+=(--signed)
299 else
300 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
301 fi
302 else
303 echo "Signing disabled for ${{ matrix.platform }}."
304 fi
305
306 bun run dist:desktop:artifact -- "${args[@]}"
307
308 - name: Collect release assets
309 shell: bash
310 run: |
311 set -euo pipefail
312 mkdir -p release-publish
313
314 shopt -s nullglob
315 for pattern in \
316 "release/*.dmg" \
317 "release/*.zip" \
318 "release/*.AppImage" \
319 "release/*.exe" \
320 "release/*.blockmap" \
321 "release/*.yml"; do
322 for file in $pattern; do
323 cp "$file" release-publish/
324 done
325 done
326
327 if [[ "${{ matrix.platform }}" == "mac" && "${{ matrix.arch }}" != "arm64" ]]; then
328 shopt -s nullglob
329 for manifest in release-publish/*-mac.yml; do
330 mv "$manifest" "${manifest%.yml}-${{ matrix.arch }}.yml"
331 done
332 fi
333
334 # Enable if Windows arm64 builds are enabled.
335 # Windows updater metadata is channel-specific (for example
336 # "latest.yml" or "nightly.yml"). Suffix each per-arch copy so the
337 # release job can merge matching arm64/x64 manifests back into one
338 # canonical manifest per channel.
339 # if [[ "${{ matrix.platform }}" == "win" ]]; then
340 # shopt -s nullglob
341 # for manifest in release-publish/*.yml; do
342 # mv "$manifest" "${manifest%.yml}-win-${{ matrix.arch }}.yml"
343 # done
344 # fi
345
346 - name: Upload build artifacts
347 uses: actions/upload-artifact@v7
348 with:
349 name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
350 path: release-publish/*
351 if-no-files-found: error
352
353 publish_cli:
354 name: Publish CLI to npm
355 needs: [preflight, build]
356 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
357 timeout-minutes: 10
358 steps:
359 - name: Checkout
360 uses: actions/checkout@v6
361 with:
362 ref: ${{ needs.preflight.outputs.ref }}
363
364 - name: Setup Bun
365 uses: oven-sh/setup-bun@v2
366 with:
367 bun-version-file: package.json
368
369 - name: Setup Node
370 uses: actions/setup-node@v6
371 with:
372 node-version-file: package.json
373 registry-url: https://registry.npmjs.org
374
375 - name: Install dependencies
376 run: bun install --frozen-lockfile
377
378 - name: Align package versions to release version
379 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
380
381 - name: Build CLI package
382 run: bun run build --filter=@t3tools/web --filter=t3
383
384 - name: Publish CLI package
385 run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose
386
387 release:
388 name: Publish GitHub Release
389 needs: [preflight, build, publish_cli]
390 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
391 timeout-minutes: 10
392 steps:
393 - name: Checkout
394 uses: actions/checkout@v6
395 with:
396 ref: ${{ needs.preflight.outputs.ref }}
397
398 - name: Setup Bun
399 uses: oven-sh/setup-bun@v2
400 with:
401 bun-version-file: package.json
402
403 - name: Setup Node
404 uses: actions/setup-node@v6
405 with:
406 node-version-file: package.json
407
408 - name: Install dependencies
409 run: bun install --frozen-lockfile
410
411 - name: Download all desktop artifacts
412 uses: actions/download-artifact@v8
413 with:
414 pattern: desktop-*
415 merge-multiple: true
416 path: release-assets
417
418 - name: Merge macOS updater manifests
419 run: |
420 shopt -s nullglob
421 for x64_manifest in release-assets/*-mac-x64.yml; do
422 arm64_manifest="${x64_manifest%-x64.yml}.yml"
423 if [[ -f "$arm64_manifest" ]]; then
424 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
425 rm -f "$x64_manifest"
426 fi
427 done
428
429 # - name: Merge Windows updater manifests
430 # run: |
431 # shopt -s nullglob
432 # found_windows_manifest=false
433 # for x64_manifest in release-assets/*-win-x64.yml; do
434 # if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
435 # continue
436 # fi
437
438 # arm64_manifest="${x64_manifest/-x64.yml/-arm64.yml}"
439 # output_manifest="${x64_manifest/-win-x64.yml/.yml}"
440 # if [[ ! -f "$arm64_manifest" ]]; then
441 # echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
442 # exit 1
443 # fi
444
445 # found_windows_manifest=true
446 # node scripts/merge-update-manifests.ts --platform win \
447 # "$arm64_manifest" \
448 # "$x64_manifest" \
449 # "$output_manifest"
450 # rm -f "$arm64_manifest" "$x64_manifest"
451 # done
452
453 # if [[ "$found_windows_manifest" != true ]]; then
454 # echo "No Windows updater manifests found to merge." >&2
455 # exit 1
456 # fi
457
458 - name: Publish release
459 if: needs.preflight.outputs.previous_tag != ''
460 uses: softprops/action-gh-release@v2
461 with:
462 tag_name: ${{ needs.preflight.outputs.tag }}
463 target_commitish: ${{ needs.preflight.outputs.ref }}
464 name: ${{ needs.preflight.outputs.release_name }}
465 generate_release_notes: true
466 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
467 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
468 make_latest: ${{ needs.preflight.outputs.make_latest }}
469 files: |
470 release-assets/*.dmg
471 release-assets/*.zip
472 release-assets/*.AppImage
473 release-assets/*.exe
474 release-assets/*.blockmap
475 release-assets/*.yml
476 fail_on_unmatched_files: true
477
478 - name: Publish first release
479 if: needs.preflight.outputs.previous_tag == ''
480 uses: softprops/action-gh-release@v2
481 with:
482 tag_name: ${{ needs.preflight.outputs.tag }}
483 target_commitish: ${{ needs.preflight.outputs.ref }}
484 name: ${{ needs.preflight.outputs.release_name }}
485 generate_release_notes: true
486 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
487 make_latest: ${{ needs.preflight.outputs.make_latest }}
488 files: |
489 release-assets/*.dmg
490 release-assets/*.zip
491 release-assets/*.AppImage
492 release-assets/*.exe
493 release-assets/*.blockmap
494 release-assets/*.yml
495 fail_on_unmatched_files: true
496
497 finalize:
498 name: Finalize release
499 if: needs.preflight.outputs.release_channel == 'stable'
500 needs: [preflight, release]
501 runs-on: blacksmith-8vcpu-ubuntu-2404
502 timeout-minutes: 10
503 steps:
504 - id: app_token
505 name: Mint release app token
506 uses: actions/create-github-app-token@v2
507 with:
508 app-id: ${{ secrets.RELEASE_APP_ID }}
509 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
510 owner: ${{ github.repository_owner }}
511
512 - name: Checkout
513 uses: actions/checkout@v6
514 with:
515 ref: main
516 fetch-depth: 0
517 token: ${{ steps.app_token.outputs.token }}
518 persist-credentials: true
519
520 - id: app_bot
521 name: Resolve GitHub App bot identity
522 env:
523 GH_TOKEN: ${{ steps.app_token.outputs.token }}
524 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
525 run: |
526 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
527 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
528 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
529
530 - name: Setup Bun
531 uses: oven-sh/setup-bun@v2
532 with:
533 bun-version-file: package.json
534
535 - name: Setup Node
536 uses: actions/setup-node@v6
537 with:
538 node-version-file: package.json
539
540 - name: Install dependencies
541 run: bun install --frozen-lockfile
542
543 - id: update_versions
544 name: Update version strings
545 env:
546 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
547 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
548
549 - name: Format package.json files
550 if: steps.update_versions.outputs.changed == 'true'
551 run: bunx oxfmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
552
553 - name: Refresh lockfile
554 if: steps.update_versions.outputs.changed == 'true'
555 run: bun install --lockfile-only --ignore-scripts
556
557 - name: Commit and push version bump
558 if: steps.update_versions.outputs.changed == 'true'
559 shell: bash
560 env:
561 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
562 run: |
563 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock; then
564 echo "No version changes to commit."
565 exit 0
566 fi
567
568 git config user.name "${{ steps.app_bot.outputs.name }}"
569 git config user.email "${{ steps.app_bot.outputs.email }}"
570
571 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock
572 git commit -m "chore(release): prepare $RELEASE_TAG"
573 git push origin HEAD:main