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