Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

release.yml

957 lines37.0 KB

1name: Release
2​
3on:
4 push:
5 tags:
6 - "v*.*.*"
7 - "!v*-nightly.*"
8 schedule:
9 - cron: "0 */3 * * *"
10 workflow_dispatch:
11 inputs:
12 channel:
13 description: "Release channel"
14 required: false
15 default: stable
16 type: choice
17 options:
18 - stable
19 - nightly
20 version:
21 description: "Release version (for example 1.2.3 or v1.2.3)"
22 required: false
23 type: string
24​
25permissions:
26 contents: read
27 id-token: none
28​
29jobs:
30 check_changes:
31 name: Check for changes since last nightly
32 if: github.event_name == 'schedule'
33 runs-on: blacksmith-8vcpu-ubuntu-2404
34 outputs:
35 has_changes: ${{ steps.check.outputs.has_changes }}
36 steps:
37 - name: Checkout
38 uses: actions/checkout@v6
39 with:
40 fetch-depth: 0
41​
42 - id: check
43 name: Compare HEAD to last nightly tag
44 run: |
45 last_nightly_tag=$(git tag --list 'v*-nightly.*' 'nightly-v*' --sort=-creatordate | head -n 1)
46 if [[ -z "$last_nightly_tag" ]]; then
47 echo "No previous nightly tag found. Proceeding with release."
48 echo "has_changes=true" >> "$GITHUB_OUTPUT"
49 exit 0
50 fi
51​
52 last_nightly_sha=$(git rev-parse "$last_nightly_tag^{commit}")
53 head_sha=$(git rev-parse HEAD)
54​
55 if [[ "$last_nightly_sha" == "$head_sha" ]]; then
56 echo "No changes on main since last nightly release ($last_nightly_tag). Skipping."
57 echo "has_changes=false" >> "$GITHUB_OUTPUT"
58 else
59 echo "Changes detected on main since $last_nightly_tag ($last_nightly_sha → $head_sha). Proceeding."
60 echo "has_changes=true" >> "$GITHUB_OUTPUT"
61 fi
62​
63 preflight:
64 name: Preflight
65 needs: [check_changes]
66 if: |
67 !failure() && !cancelled() &&
68 (github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
69 runs-on: blacksmith-8vcpu-ubuntu-2404
70 timeout-minutes: 10
71 outputs:
72 release_channel: ${{ steps.release_meta.outputs.release_channel }}
73 version: ${{ steps.release_meta.outputs.version }}
74 tag: ${{ steps.release_meta.outputs.tag }}
75 release_name: ${{ steps.release_meta.outputs.name }}
76 short_sha: ${{ steps.release_meta.outputs.short_sha }}
77 previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
78 cli_dist_tag: ${{ steps.release_meta.outputs.cli_dist_tag }}
79 is_prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
80 make_latest: ${{ steps.release_meta.outputs.make_latest }}
81 ref: ${{ github.sha }}
82 steps:
83 - name: Checkout
84 uses: actions/checkout@v6
85 with:
86 fetch-depth: 0
87​
88 - name: Setup Vite+
89 uses: voidzero-dev/setup-vp@v1
90 with:
91 node-version-file: package.json
92 cache: true
93 run-install: true
94​
95 - name: Ensure Electron runtime is installed
96 run: vp run --filter @t3tools/desktop ensure:electron
97​
98 - id: release_meta
99 name: Resolve release version
100 shell: bash
101 env:
102 DISPATCH_CHANNEL: ${{ github.event.inputs.channel }}
103 DISPATCH_VERSION: ${{ github.event.inputs.version }}
104 NIGHTLY_DATE: ${{ github.run_started_at }}
105 NIGHTLY_SHA: ${{ github.sha }}
106 NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
107 run: |
108 if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "nightly" ) ]]; then
109 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
110​
111 node scripts/resolve-nightly-release.ts \
112 --date "$nightly_date" \
113 --run-number "$NIGHTLY_RUN_NUMBER" \
114 --sha "$NIGHTLY_SHA" \
115 --github-output
116​
117 echo "release_channel=nightly" >> "$GITHUB_OUTPUT"
118 echo "cli_dist_tag=nightly" >> "$GITHUB_OUTPUT"
119 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
120 echo "make_latest=false" >> "$GITHUB_OUTPUT"
121 else
122 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
123 raw="${DISPATCH_VERSION}"
124 if [[ -z "$raw" ]]; then
125 echo "workflow_dispatch stable releases require the version input." >&2
126 exit 1
127 fi
128 else
129 raw="${GITHUB_REF_NAME}"
130 fi
131​
132 version="${raw#v}"
133 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
134 echo "Invalid release version: $raw" >&2
135 exit 1
136 fi
137​
138 echo "release_channel=stable" >> "$GITHUB_OUTPUT"
139 echo "version=$version" >> "$GITHUB_OUTPUT"
140 echo "tag=v$version" >> "$GITHUB_OUTPUT"
141 echo "name=T3 Code v$version" >> "$GITHUB_OUTPUT"
142 echo "cli_dist_tag=latest" >> "$GITHUB_OUTPUT"
143 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
144 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
145 echo "make_latest=true" >> "$GITHUB_OUTPUT"
146 else
147 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
148 echo "make_latest=false" >> "$GITHUB_OUTPUT"
149 fi
150 fi
151​
152 - name: Check
153 run: vp check
154​
155 - name: Typecheck
156 run: vp run typecheck
157​
158 - name: Test
159 run: vp run test
160​
161 - id: previous_tag
162 name: Resolve previous release tag
163 run: |
164 node scripts/resolve-previous-release-tag.ts \
165 --channel "${{ steps.release_meta.outputs.release_channel }}" \
166 --current-tag "${{ steps.release_meta.outputs.tag }}" \
167 --github-output
168​
169 relay_public_config:
170 name: Resolve T3 Connect public config
171 needs: preflight
172 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
173 runs-on: blacksmith-8vcpu-ubuntu-2404
174 timeout-minutes: 5
175 environment:
176 name: production
177 outputs:
178 clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
179 clerk_jwt_template: ${{ steps.public_config.outputs.clerk_jwt_template }}
180 clerk_cli_oauth_client_id: ${{ steps.public_config.outputs.clerk_cli_oauth_client_id }}
181 relay_url: ${{ steps.public_config.outputs.relay_url }}
182 env:
183 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
184 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
185 RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
186 RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
187 CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
188 CLERK_JWT_TEMPLATE: ${{ vars.CLERK_JWT_TEMPLATE }}
189 CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.CLERK_CLI_OAUTH_CLIENT_ID }}
190 steps:
191 - name: Checkout
192 uses: actions/checkout@v6
193 with:
194 ref: ${{ needs.preflight.outputs.ref }}
195​
196 - name: Setup Vite+
197 uses: voidzero-dev/setup-vp@v1
198 with:
199 node-version-file: package.json
200 cache: true
201 run-install: |
202 args:
203 - --filter=t3code-relay...
204​
205 - id: relay_state
206 name: Read production relay tracing config
207 shell: bash
208 run: |
209 vp run --filter t3code-relay deploy \
210 --stage prod \
211 --read-state \
212 --github-output \
213 --github-env-file "$RUNNER_TEMP/relay-client-tracing.env"
214​
215 - name: Upload relay client tracing config
216 uses: actions/upload-artifact@v7
217 with:
218 name: relay-client-tracing-config
219 path: ${{ runner.temp }}/relay-client-tracing.env
220 if-no-files-found: error
221 retention-days: 1
222​
223 - id: public_config
224 name: Resolve production relay public config
225 shell: bash
226 run: |
227 set -euo pipefail
228​
229 relay_domain="${RELAY_DOMAIN:-}"
230 if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
231 relay_domain="relay.$RELAY_API_ZONE_NAME"
232 fi
233 required=(
234 relay_domain
235 CLERK_PUBLISHABLE_KEY
236 CLERK_JWT_TEMPLATE
237 CLERK_CLI_OAUTH_CLIENT_ID
238 )
239 missing=()
240 for name in "${required[@]}"; do
241 if [[ -z "${!name:-}" ]]; then
242 missing+=("$name")
243 fi
244 done
245 if (( ${#missing[@]} > 0 )); then
246 printf 'Missing required relay deployment configuration: %s\n' "${missing[*]}" >&2
247 exit 1
248 fi
249​
250 echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
251 echo "clerk_jwt_template=$CLERK_JWT_TEMPLATE" >> "$GITHUB_OUTPUT"
252 echo "clerk_cli_oauth_client_id=$CLERK_CLI_OAUTH_CLIENT_ID" >> "$GITHUB_OUTPUT"
253 echo "relay_url=https://$relay_domain" >> "$GITHUB_OUTPUT"
254​
255 build:
256 name: Build ${{ matrix.label }}
257 needs: [preflight, relay_public_config]
258 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
259 runs-on: ${{ matrix.runner }}
260 timeout-minutes: 30
261 env:
262 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
263 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
264 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
265 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
266 strategy:
267 fail-fast: false
268 matrix:
269 include:
270 - label: macOS arm64
271 runner: blacksmith-12vcpu-macos-26
272 platform: mac
273 target: dmg
274 arch: arm64
275 - label: macOS x64
276 runner: blacksmith-12vcpu-macos-26
277 platform: mac
278 target: dmg
279 arch: x64
280 - label: Linux x64
281 runner: blacksmith-32vcpu-ubuntu-2404
282 platform: linux
283 target: AppImage
284 arch: x64
285 - label: Windows x64
286 runner: blacksmith-32vcpu-windows-2025
287 platform: win
288 target: nsis
289 arch: x64
290 # - label: Windows arm64
291 # runner: windows-11-arm
292 # platform: win
293 # target: nsis
294 # arch: arm64
295 steps:
296 - name: Checkout
297 uses: actions/checkout@v6
298 with:
299 ref: ${{ needs.preflight.outputs.ref }}
300 fetch-depth: 0
301​
302 - name: Setup Vite+
303 uses: voidzero-dev/setup-vp@v1
304 with:
305 node-version-file: package.json
306 cache: true
307 run-install: true
308​
309 - name: Download relay client tracing config
310 uses: actions/download-artifact@v8
311 with:
312 name: relay-client-tracing-config
313 path: ${{ runner.temp }}/relay-client-tracing
314​
315 - name: Load relay client tracing config
316 shell: bash
317 run: |
318 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
319 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
320 echo "::add-mask::$tracing_token"
321 cat "$config_path" >> "$GITHUB_ENV"
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: Install Spectre-mitigated MSVC libs
327 if: matrix.platform == 'win'
328 shell: pwsh
329 run: |
330 $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
331 $installPath = & $vswhere -products * -latest -property installationPath
332 $setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
333 $proc = Start-Process -FilePath $setupExe `
334 -ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
335 "Microsoft.VisualStudio.Component.VC.Tools.x86.x64.Spectre", "--quiet", "--norestart" `
336 -Wait -PassThru -NoNewWindow
337 if ($null -eq $proc -or $proc.ExitCode -ne 0) {
338 $code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
339 Write-Error "Visual Studio Installer failed with exit code $code"
340 exit $code
341 }
342​
343 - name: Install ImageMagick
344 if: matrix.platform == 'linux'
345 shell: bash
346 run: |
347 if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
348 sudo apt-get update
349 sudo apt-get install -y imagemagick
350 fi
351​
352 if command -v magick >/dev/null 2>&1; then
353 magick -version
354 else
355 convert -version
356 fi
357​
358 - name: Prepare Azure Trusted Signing
359 if: matrix.platform == 'win'
360 shell: pwsh
361 env:
362 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
363 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
364 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
365 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
366 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
367 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
368 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
369 run: |
370 $ErrorActionPreference = "Stop"
371​
372 $requiredSecrets = @(
373 $env:AZURE_TENANT_ID,
374 $env:AZURE_CLIENT_ID,
375 $env:AZURE_CLIENT_SECRET,
376 $env:AZURE_TRUSTED_SIGNING_ENDPOINT,
377 $env:AZURE_TRUSTED_SIGNING_ACCOUNT_NAME,
378 $env:AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME,
379 $env:AZURE_TRUSTED_SIGNING_PUBLISHER_NAME
380 )
381 if ($requiredSecrets | Where-Object { [string]::IsNullOrWhiteSpace($_) }) {
382 Write-Host "Azure Trusted Signing disabled; skipping TrustedSigning module preparation."
383 exit 0
384 }
385​
386 try {
387 Install-PackageProvider `
388 -Name NuGet `
389 -MinimumVersion 2.8.5.201 `
390 -Force `
391 -Scope CurrentUser `
392 -ErrorAction Stop
393 } catch {
394 Write-Warning "Could not bootstrap NuGet package provider. Continuing because the runner may already have a usable provider. $($_.Exception.Message)"
395 }
396​
397 Install-Module `
398 -Name TrustedSigning `
399 -MinimumVersion 0.5.0 `
400 -Force `
401 -AllowClobber `
402 -Repository PSGallery `
403 -Scope CurrentUser `
404 -ErrorAction Stop
405​
406 Import-Module TrustedSigning -MinimumVersion 0.5.0 -Force
407 Get-Command Invoke-TrustedSigning -ErrorAction Stop
408​
409 $moduleRoots = @(
410 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "PowerShell", "Modules"),
411 [System.IO.Path]::Combine([Environment]::GetFolderPath("MyDocuments"), "WindowsPowerShell", "Modules"),
412 [System.IO.Path]::Combine($env:ProgramFiles, "PowerShell", "Modules"),
413 [System.IO.Path]::Combine($env:ProgramFiles, "WindowsPowerShell", "Modules")
414 )
415 $modulePathEntries = @($moduleRoots + ($env:PSModulePath -split ";")) |
416 Where-Object { $_ -and (Test-Path $_) } |
417 Select-Object -Unique
418 "PSModulePath=$($modulePathEntries -join ';')" >> $env:GITHUB_ENV
419​
420 - name: Build desktop artifact
421 shell: bash
422 env:
423 CSC_LINK: ${{ secrets.CSC_LINK }}
424 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
425 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
426 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
427 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
428 APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
429 MACOS_PROVISIONING_PROFILE: ${{ secrets.MACOS_PROVISIONING_PROFILE }}
430 T3CODE_CLERK_PASSKEY_RP_DOMAINS: ${{ vars.CLERK_PASSKEY_RP_DOMAINS }}
431 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
432 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
433 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
434 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
435 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
436 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
437 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
438 run: |
439 args=(
440 --platform "${{ matrix.platform }}"
441 --target "${{ matrix.target }}"
442 --arch "${{ matrix.arch }}"
443 --build-version "${{ needs.preflight.outputs.version }}"
444 --verbose
445 )
446​
447 has_all() {
448 for value in "$@"; do
449 if [[ -z "$value" ]]; then
450 return 1
451 fi
452 done
453 return 0
454 }
455​
456 if [[ "${{ matrix.platform }}" == "mac" ]]; then
457 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
458 if ! has_all "$APPLE_TEAM_ID" "$MACOS_PROVISIONING_PROFILE"; then
459 echo "macOS signing is configured, but APPLE_TEAM_ID or MACOS_PROVISIONING_PROFILE is missing." >&2
460 exit 1
461 fi
462​
463 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
464 printf '%s' "$APPLE_API_KEY" > "$key_path"
465 export APPLE_API_KEY="$key_path"
466​
467 profile_path="$RUNNER_TEMP/t3code.provisionprofile"
468 printf '%s' "$MACOS_PROVISIONING_PROFILE" | base64 -D > "$profile_path"
469 security cms -D -i "$profile_path" >/dev/null
470 export T3CODE_APPLE_TEAM_ID="$APPLE_TEAM_ID"
471 export T3CODE_MACOS_PROVISIONING_PROFILE="$profile_path"
472​
473 echo "macOS signing enabled."
474 args+=(--signed)
475 else
476 echo "macOS signing disabled (missing one or more Apple signing secrets)."
477 fi
478 elif [[ "${{ matrix.platform }}" == "win" ]]; then
479 if has_all \
480 "$AZURE_TENANT_ID" \
481 "$AZURE_CLIENT_ID" \
482 "$AZURE_CLIENT_SECRET" \
483 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
484 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
485 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
486 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
487 echo "Windows signing enabled (Azure Trusted Signing)."
488 args+=(--signed)
489 else
490 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
491 fi
492 else
493 echo "Signing disabled for ${{ matrix.platform }}."
494 fi
495​
496 vp run dist:desktop:artifact "${args[@]}"
497​
498 - name: Collect release assets
499 shell: bash
500 run: |
501 set -euo pipefail
502 mkdir -p release-publish
503​
504 shopt -s nullglob
505 for pattern in \
506 "release/*.dmg" \
507 "release/*.zip" \
508 "release/*.AppImage" \
509 "release/*.exe" \
510 "release/*.blockmap" \
511 "release/*.yml"; do
512 for file in $pattern; do
513 cp "$file" release-publish/
514 done
515 done
516​
517 if [[ "${{ matrix.platform }}" == "mac" && "${{ matrix.arch }}" != "arm64" ]]; then
518 shopt -s nullglob
519 for manifest in release-publish/*-mac.yml; do
520 mv "$manifest" "${manifest%.yml}-${{ matrix.arch }}.yml"
521 done
522 fi
523​
524 # Enable if Windows arm64 builds are enabled.
525 # Windows updater metadata is channel-specific (for example
526 # "latest.yml" or "nightly.yml"). Suffix each per-arch copy so the
527 # release job can merge matching arm64/x64 manifests back into one
528 # canonical manifest per channel.
529 # if [[ "${{ matrix.platform }}" == "win" ]]; then
530 # shopt -s nullglob
531 # for manifest in release-publish/*.yml; do
532 # mv "$manifest" "${manifest%.yml}-win-${{ matrix.arch }}.yml"
533 # done
534 # fi
535​
536 - name: Upload build artifacts
537 uses: actions/upload-artifact@v7
538 with:
539 name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
540 path: release-publish/*
541 if-no-files-found: error
542​
543 publish_cli:
544 name: Publish CLI to npm
545 needs: [preflight, relay_public_config, build]
546 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build.result == 'success' }}
547 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
548 timeout-minutes: 10
549 permissions:
550 contents: read
551 id-token: write
552 env:
553 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
554 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
555 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
556 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
557 steps:
558 - name: Checkout
559 uses: actions/checkout@v6
560 with:
561 ref: ${{ needs.preflight.outputs.ref }}
562​
563 - name: Setup Vite+
564 uses: voidzero-dev/setup-vp@v1
565 with:
566 node-version-file: package.json
567 cache: true
568 run-install: |
569 args:
570 - --filter=t3...
571 - --filter=@t3tools/web...
572 - --filter=@t3tools/scripts...
573​
574 - name: Download relay client tracing config
575 uses: actions/download-artifact@v8
576 with:
577 name: relay-client-tracing-config
578 path: ${{ runner.temp }}/relay-client-tracing
579​
580 - name: Load relay client tracing config
581 shell: bash
582 run: |
583 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
584 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
585 echo "::add-mask::$tracing_token"
586 cat "$config_path" >> "$GITHUB_ENV"
587​
588 - name: Align package versions to release version
589 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
590​
591 - name: Build web package
592 run: vp run --filter @t3tools/web build
593​
594 - name: Build CLI package
595 run: vp run --filter t3 build
596​
597 - name: Publish CLI package
598 run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose
599​
600 release:
601 name: Publish GitHub Release
602 needs: [preflight, build, publish_cli]
603 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' && needs.publish_cli.result == 'success' }}
604 runs-on: blacksmith-8vcpu-ubuntu-2404
605 timeout-minutes: 10
606 steps:
607 - id: app_token
608 name: Mint release app token
609 uses: actions/create-github-app-token@v2
610 with:
611 app-id: ${{ secrets.RELEASE_APP_ID }}
612 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
613 owner: ${{ github.repository_owner }}
614​
615 - name: Checkout
616 uses: actions/checkout@v6
617 with:
618 ref: ${{ needs.preflight.outputs.ref }}
619​
620 - name: Setup Vite+
621 uses: voidzero-dev/setup-vp@v1
622 with:
623 node-version-file: package.json
624 cache: true
625 run-install: |
626 args:
627 - --filter=@t3tools/scripts...
628​
629 - name: Download all desktop artifacts
630 uses: actions/download-artifact@v8
631 with:
632 pattern: desktop-*
633 merge-multiple: true
634 path: release-assets
635​
636 - name: Merge macOS updater manifests
637 run: |
638 shopt -s nullglob
639 for x64_manifest in release-assets/*-mac-x64.yml; do
640 arm64_manifest="${x64_manifest%-x64.yml}.yml"
641 if [[ -f "$arm64_manifest" ]]; then
642 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
643 rm -f "$x64_manifest"
644 fi
645 done
646​
647 # - name: Merge Windows updater manifests
648 # run: |
649 # shopt -s nullglob
650 # found_windows_manifest=false
651 # for x64_manifest in release-assets/*-win-x64.yml; do
652 # if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
653 # continue
654 # fi
655​
656 # arm64_manifest="${x64_manifest/-x64.yml/-arm64.yml}"
657 # output_manifest="${x64_manifest/-win-x64.yml/.yml}"
658 # if [[ ! -f "$arm64_manifest" ]]; then
659 # echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
660 # exit 1
661 # fi
662​
663 # found_windows_manifest=true
664 # node scripts/merge-update-manifests.ts --platform win \
665 # "$arm64_manifest" \
666 # "$x64_manifest" \
667 # "$output_manifest"
668 # rm -f "$arm64_manifest" "$x64_manifest"
669 # done
670​
671 # if [[ "$found_windows_manifest" != true ]]; then
672 # echo "No Windows updater manifests found to merge." >&2
673 # exit 1
674 # fi
675​
676 - name: Publish release
677 if: needs.preflight.outputs.previous_tag != ''
678 uses: softprops/action-gh-release@v2
679 with:
680 tag_name: ${{ needs.preflight.outputs.tag }}
681 target_commitish: ${{ needs.preflight.outputs.ref }}
682 name: ${{ needs.preflight.outputs.release_name }}
683 generate_release_notes: true
684 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
685 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
686 make_latest: ${{ needs.preflight.outputs.make_latest }}
687 files: |
688 release-assets/*.dmg
689 release-assets/*.zip
690 release-assets/*.AppImage
691 release-assets/*.exe
692 release-assets/*.blockmap
693 release-assets/*.yml
694 fail_on_unmatched_files: true
695 token: ${{ steps.app_token.outputs.token }}
696​
697 - name: Publish first release
698 if: needs.preflight.outputs.previous_tag == ''
699 uses: softprops/action-gh-release@v2
700 with:
701 tag_name: ${{ needs.preflight.outputs.tag }}
702 target_commitish: ${{ needs.preflight.outputs.ref }}
703 name: ${{ needs.preflight.outputs.release_name }}
704 generate_release_notes: true
705 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
706 make_latest: ${{ needs.preflight.outputs.make_latest }}
707 files: |
708 release-assets/*.dmg
709 release-assets/*.zip
710 release-assets/*.AppImage
711 release-assets/*.exe
712 release-assets/*.blockmap
713 release-assets/*.yml
714 fail_on_unmatched_files: true
715 token: ${{ steps.app_token.outputs.token }}
716​
717 deploy_web:
718 name: Deploy hosted web app
719 needs: [preflight, relay_public_config, release]
720 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.release.result == 'success' }}
721 runs-on: blacksmith-8vcpu-ubuntu-2404
722 timeout-minutes: 10
723 env:
724 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
725 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
726 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
727 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
728 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
729 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
730 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
731 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
732 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
733 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
734 steps:
735 - name: Checkout
736 uses: actions/checkout@v6
737 with:
738 ref: ${{ needs.preflight.outputs.ref }}
739​
740 - name: Setup Vite+
741 uses: voidzero-dev/setup-vp@v1
742 with:
743 node-version-file: package.json
744 cache: true
745 run-install: |
746 args:
747 - --filter=@t3tools/scripts...
748 - --filter=@t3tools/web...
749​
750 - name: Download relay client tracing config
751 uses: actions/download-artifact@v8
752 with:
753 name: relay-client-tracing-config
754 path: ${{ runner.temp }}/relay-client-tracing
755​
756 - name: Load relay client tracing config
757 shell: bash
758 run: |
759 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
760 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
761 echo "::add-mask::$tracing_token"
762 cat "$config_path" >> "$GITHUB_ENV"
763​
764 - name: Align package versions to release version
765 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
766​
767 - name: Refresh release lockfile
768 run: vp install --lockfile-only --ignore-scripts
769​
770 - name: Deploy and alias channel
771 shell: bash
772 run: |
773 set -euo pipefail
774​
775 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
776 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
777 exit 1
778 fi
779​
780 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
781 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
782 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
783 router_domain="${router_url#http://}"
784 router_domain="${router_domain#https://}"
785 router_domain="${router_domain%%/*}"
786​
787 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
788 channel_domain="$latest_domain"
789 channel_name="latest"
790 else
791 channel_domain="$nightly_domain"
792 channel_name="nightly"
793 fi
794​
795 vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
796 vercel_scope_args=(--scope "$vercel_scope")
797​
798 echo "Deploying hosted web app for $channel_name channel."
799 deployment_url="$(
800 vp dlx vercel@53.1.1 deploy \
801 --prod \
802 --skip-domain \
803 --yes \
804 --token "$VERCEL_TOKEN" \
805 "${vercel_scope_args[@]}" \
806 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
807 --build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \
808 --build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \
809 --build-env "T3CODE_RELAY_URL=${T3CODE_RELAY_URL:-}" \
810 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=${T3CODE_RELAY_CLIENT_OTLP_TRACES_URL:-}" \
811 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=${T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET:-}" \
812 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=${T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN:-}" \
813 --build-env "VITE_HOSTED_APP_URL=$router_url" \
814 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
815 )"
816​
817 echo "Aliasing $deployment_url to $channel_domain."
818 vp dlx vercel@53.1.1 alias set "$deployment_url" "$channel_domain" \
819 --token "$VERCEL_TOKEN" \
820 "${vercel_scope_args[@]}"
821​
822 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
823 echo "Aliasing $deployment_url to router domain $router_domain."
824 vp dlx vercel@53.1.1 alias set "$deployment_url" "$router_domain" \
825 --token "$VERCEL_TOKEN" \
826 "${vercel_scope_args[@]}"
827 fi
828​
829 finalize:
830 name: Finalize release
831 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
832 needs: [preflight, release]
833 runs-on: blacksmith-8vcpu-ubuntu-2404
834 timeout-minutes: 10
835 steps:
836 - id: app_token
837 name: Mint release app token
838 uses: actions/create-github-app-token@v2
839 with:
840 app-id: ${{ secrets.RELEASE_APP_ID }}
841 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
842 owner: ${{ github.repository_owner }}
843​
844 - name: Checkout
845 uses: actions/checkout@v6
846 with:
847 ref: main
848 fetch-depth: 0
849 token: ${{ steps.app_token.outputs.token }}
850 persist-credentials: true
851​
852 - id: app_bot
853 name: Resolve GitHub App bot identity
854 env:
855 GH_TOKEN: ${{ steps.app_token.outputs.token }}
856 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
857 run: |
858 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
859 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
860 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
861​
862 - name: Setup Vite+
863 uses: voidzero-dev/setup-vp@v1
864 with:
865 node-version-file: package.json
866 cache: true
867 run-install: |
868 args:
869 - --filter=@t3tools/scripts...
870 - --filter=@t3tools/oxlint-plugin-t3code...
871​
872 - id: update_versions
873 name: Update version strings
874 env:
875 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
876 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
877​
878 - name: Format package.json files
879 if: steps.update_versions.outputs.changed == 'true'
880 run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
881​
882 - name: Refresh lockfile
883 if: steps.update_versions.outputs.changed == 'true'
884 run: vp install --lockfile-only --ignore-scripts
885​
886 - name: Commit and push version bump
887 if: steps.update_versions.outputs.changed == 'true'
888 shell: bash
889 env:
890 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
891 run: |
892 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml; then
893 echo "No version changes to commit."
894 exit 0
895 fi
896​
897 git config user.name "${{ steps.app_bot.outputs.name }}"
898 git config user.email "${{ steps.app_bot.outputs.email }}"
899​
900 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
901 git commit -m "chore(release): prepare $RELEASE_TAG"
902 git push origin HEAD:main
903​
904 announce_discord:
905 name: Announce release on Discord
906 if: |
907 always() && !cancelled() &&
908 needs.preflight.result == 'success' &&
909 needs.relay_public_config.result == 'success' &&
910 needs.release.result == 'success' &&
911 needs.deploy_web.result == 'success' &&
912 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
913 needs: [preflight, relay_public_config, release, deploy_web, finalize]
914 runs-on: blacksmith-8vcpu-ubuntu-2404
915 timeout-minutes: 10
916 steps:
917 - name: Checkout
918 uses: actions/checkout@v6
919 with:
920 ref: ${{ needs.preflight.outputs.ref }}
921​
922 - name: Setup Vite+
923 uses: voidzero-dev/setup-vp@v1
924 with:
925 node-version-file: package.json
926 cache: true
927 run-install: |
928 args:
929 - --filter=@t3tools/scripts...
930​
931 - name: Announce prerelease on Discord
932 if: needs.preflight.outputs.is_prerelease == 'true'
933 continue-on-error: true
934 env:
935 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
936 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
937 run: |
938 node scripts/notify-discord-release.ts prerelease \
939 --role-id "$DISCORD_MENTION_ROLE_ID" \
940 --release-name "${{ needs.preflight.outputs.release_name }}" \
941 --release-version "${{ needs.preflight.outputs.version }}" \
942 --tag "${{ needs.preflight.outputs.tag }}" \
943 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"
944​
945 - name: Announce latest release on Discord
946 if: needs.preflight.outputs.make_latest == 'true'
947 continue-on-error: true
948 env:
949 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
950 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
951 run: |
952 node scripts/notify-discord-release.ts latest \
953 --role-id "$DISCORD_MENTION_ROLE_ID" \
954 --release-name "${{ needs.preflight.outputs.release_name }}" \
955 --release-version "${{ needs.preflight.outputs.version }}" \
956 --tag "${{ needs.preflight.outputs.tag }}" \
957 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"