Open History to see the last commit
1name: Release
2
3on:
4 push:
5 tags:
6 - "v*.*.*"
7 - "!v*-nightly.*"
8 - "!v*-preview.*"
9 schedule:
10 # Avoid minute zero, when GitHub scheduled jobs are busiest.
11 - cron: "8,38 * * * *"
12 workflow_dispatch:
13 inputs:
14 channel:
15 description: "Release channel"
16 required: false
17 default: preview
18 type: choice
19 options:
20 - preview
21 - stable
22 - nightly
23 version:
24 description: "Stable version override (for example 1.2.3). Defaults to the version the latest nightly previewed."
25 required: false
26 type: string
27
28# Serialize nightlies (scheduled and manual) so overlapping runs cannot build
29# the same commit twice or publish out of order. Stable tag releases get their
30# own group so a nightly never blocks them. Running publishers are never
31# canceled, and queue: max keeps every pending run instead of the default
32# newest-wins single slot, so a queued stable tag can never be silently
33# dropped. Automatic nightlies recheck the release gap after leaving the queue.
34concurrency:
35 group: release-${{ (github.event_name == 'schedule' || inputs.channel == 'nightly' || inputs.channel == 'preview') && 'nightly' || 'stable' }}
36 cancel-in-progress: false
37 queue: max
38
39permissions:
40 # The Windows desktop jobs read this run's artifact list to wait for the
41 # Linux CLI archive they embed (see release-desktop.yml).
42 actions: read
43 contents: read
44 id-token: none
45
46jobs:
47 # Picks the commit every later job builds. Nightlies and tag pushes build the
48 # triggering commit. Manual stable releases build the commit of the latest
49 # published nightly, so stable only ever ships a build that nightly users
50 # have already run. Scheduled runs also decide here whether a nightly is due.
51 resolve_commit:
52 name: Resolve release commit
53 if: github.repository == 'pingdotgg/t3code'
54 runs-on: blacksmith-8vcpu-ubuntu-2404
55 timeout-minutes: 5
56 outputs:
57 ref: ${{ steps.resolve.outputs.ref }}
58 nightly_version: ${{ steps.resolve.outputs.nightly_version }}
59 has_changes: ${{ steps.resolve.outputs.has_changes }}
60 steps:
61 - name: Checkout
62 uses: actions/checkout@v6
63 with:
64 sparse-checkout: .github/scripts
65
66 - id: resolve
67 name: Resolve release commit
68 uses: actions/github-script@v8
69 env:
70 DISPATCH_CHANNEL: ${{ inputs.channel }}
71 with:
72 script: |
73 const {
74 assertCommitOnDefaultBranch,
75 assertReleaseSource,
76 shouldReleaseNightly,
77 resolveLatestNightlyCommit,
78 } = require('./.github/scripts/check-nightly-release.cjs');
79
80 const dispatchChannel = process.env.DISPATCH_CHANNEL || 'preview';
81 const releaseChannel = context.eventName === 'schedule'
82 ? 'nightly'
83 : context.eventName === 'workflow_dispatch'
84 ? dispatchChannel
85 : 'stable';
86
87 await assertReleaseSource({ github, context, releaseChannel });
88
89 if (context.eventName === 'schedule') {
90 core.setOutput('has_changes', await shouldReleaseNightly({ github, context, core }));
91 core.setOutput('ref', context.sha);
92 } else if (context.eventName === 'workflow_dispatch' && dispatchChannel === 'stable') {
93 const { tag, sha, version } = await resolveLatestNightlyCommit({ github, context, core });
94 await assertCommitOnDefaultBranch({ github, context, sha });
95 core.notice(`Stable release builds ${sha}, the commit shipped by ${tag}.`);
96 core.setOutput('ref', sha);
97 core.setOutput('nightly_version', version);
98 } else {
99 core.setOutput('ref', context.sha);
100 }
101
102 preflight:
103 name: Preflight
104 needs: [resolve_commit]
105 if: |
106 needs.resolve_commit.result == 'success' &&
107 (github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
108 runs-on: blacksmith-8vcpu-ubuntu-2404
109 timeout-minutes: 10
110 outputs:
111 release_channel: ${{ steps.release_meta.outputs.release_channel }}
112 version: ${{ steps.release_meta.outputs.version }}
113 tag: ${{ steps.release_meta.outputs.tag }}
114 release_name: ${{ steps.release_meta.outputs.name }}
115 short_sha: ${{ steps.release_meta.outputs.short_sha }}
116 previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
117 cli_dist_tag: ${{ steps.release_meta.outputs.cli_dist_tag }}
118 is_prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
119 make_latest: ${{ steps.release_meta.outputs.make_latest }}
120 ref: ${{ needs.resolve_commit.outputs.ref }}
121 steps:
122 - name: Checkout
123 uses: actions/checkout@v6
124 with:
125 ref: ${{ needs.resolve_commit.outputs.ref }}
126 fetch-depth: 0
127 sparse-checkout: |
128 /*
129 !/.repos/
130 sparse-checkout-cone-mode: false
131
132 - name: Setup dependencies
133 uses: ./.github/actions/setup-ci-deps
134 with:
135 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
136 env:
137 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
138
139 - id: release_meta
140 name: Resolve release version
141 shell: bash
142 env:
143 DISPATCH_CHANNEL: ${{ github.event.inputs.channel }}
144 DISPATCH_VERSION: ${{ github.event.inputs.version }}
145 NIGHTLY_VERSION: ${{ needs.resolve_commit.outputs.nightly_version }}
146 NIGHTLY_DATE: ${{ github.run_started_at }}
147 NIGHTLY_SHA: ${{ needs.resolve_commit.outputs.ref }}
148 NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
149 run: |
150 if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-preview}" == "nightly" ) ]]; then
151 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
152
153 node scripts/resolve-nightly-release.ts \
154 --date "$nightly_date" \
155 --run-number "$NIGHTLY_RUN_NUMBER" \
156 --sha "$NIGHTLY_SHA" \
157 --github-output
158
159 echo "release_channel=nightly" >> "$GITHUB_OUTPUT"
160 echo "cli_dist_tag=nightly" >> "$GITHUB_OUTPUT"
161 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
162 echo "make_latest=false" >> "$GITHUB_OUTPUT"
163 elif [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-preview}" == "preview" ]]; then
164 # Manual-only test train: exercises the whole release flow for a
165 # commit end users must never receive. Never scheduled.
166 # Same versioning as nightly under its own prerelease identifier.
167 # A preview release is reachable only by asking for it: npm gets it
168 # under the `preview` dist-tag, which nothing resolves by default,
169 # its desktop builds carry no update feed, and no updater manifest
170 # is attached to the release, so neither stable nor nightly
171 # installs can ever be offered one.
172 nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
173
174 node scripts/resolve-nightly-release.ts \
175 --channel preview \
176 --date "$nightly_date" \
177 --run-number "$NIGHTLY_RUN_NUMBER" \
178 --sha "$NIGHTLY_SHA" \
179 --github-output
180
181 echo "release_channel=preview" >> "$GITHUB_OUTPUT"
182 echo "cli_dist_tag=preview" >> "$GITHUB_OUTPUT"
183 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
184 echo "make_latest=false" >> "$GITHUB_OUTPUT"
185 else
186 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
187 raw="${DISPATCH_VERSION:-$NIGHTLY_VERSION}"
188 if [[ -z "$raw" ]]; then
189 echo "workflow_dispatch stable releases need a version input or a published nightly." >&2
190 exit 1
191 fi
192 else
193 raw="${GITHUB_REF_NAME}"
194 fi
195
196 version="${raw#v}"
197 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
198 echo "Invalid release version: $raw" >&2
199 exit 1
200 fi
201
202 echo "release_channel=stable" >> "$GITHUB_OUTPUT"
203 echo "version=$version" >> "$GITHUB_OUTPUT"
204 echo "tag=v$version" >> "$GITHUB_OUTPUT"
205 echo "name=T3 Code v$version" >> "$GITHUB_OUTPUT"
206 echo "cli_dist_tag=latest" >> "$GITHUB_OUTPUT"
207 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
208 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
209 echo "make_latest=true" >> "$GITHUB_OUTPUT"
210 else
211 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
212 echo "make_latest=false" >> "$GITHUB_OUTPUT"
213 fi
214 fi
215
216 - id: previous_tag
217 name: Resolve previous release tag
218 run: |
219 node scripts/resolve-previous-release-tag.ts \
220 --channel "${{ steps.release_meta.outputs.release_channel }}" \
221 --current-tag "${{ steps.release_meta.outputs.tag }}" \
222 --github-output
223
224 # Share only the verification results, not the large registry metadata cache.
225 - name: Upload dependency verification
226 continue-on-error: true
227 uses: actions/upload-artifact@v7
228 with:
229 name: release-dependency-verification
230 path: ${{ runner.temp }}/pnpm-metadata/lockfile-verified.jsonl
231
232 quality:
233 name: Release quality checks
234 needs: [preflight]
235 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
236 runs-on: blacksmith-8vcpu-ubuntu-2404
237 timeout-minutes: 10
238 steps:
239 - name: Checkout
240 uses: actions/checkout@v6
241 with:
242 ref: ${{ needs.preflight.outputs.ref }}
243 sparse-checkout: |
244 /*
245 !/.repos/
246 sparse-checkout-cone-mode: false
247
248 - name: Setup dependencies
249 uses: ./.github/actions/setup-ci-deps
250 with:
251 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
252
253 - name: Ensure Electron runtime is installed
254 run: vp run --filter @t3tools/desktop ensure:electron
255
256 - name: Check
257 run: vp check
258
259 - name: Typecheck
260 run: vp run typecheck
261
262 # Keep tests on their own runners, using the same package split and server
263 # shards as CI (test, test_web, test_server in ci.yml). Keep the two in sync.
264 test:
265 name: Release tests
266 needs: [preflight]
267 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
268 runs-on: blacksmith-8vcpu-ubuntu-2404
269 timeout-minutes: 10
270 steps:
271 - name: Checkout
272 uses: actions/checkout@v6
273 with:
274 ref: ${{ needs.preflight.outputs.ref }}
275 sparse-checkout: |
276 /*
277 !/.repos/
278 sparse-checkout-cone-mode: false
279
280 - name: Setup dependencies
281 uses: ./.github/actions/setup-ci-deps
282 with:
283 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
284
285 - name: Ensure Electron runtime is installed
286 run: vp run --filter @t3tools/desktop ensure:electron
287
288 - uses: ./.github/actions/setup-apt-mirrors
289
290 - name: Install browser secret helper build libraries
291 run: |
292 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
293 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config build-essential
294
295 - name: Test
296 run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web' test
297
298 # Web browser tests time out when they share a runner with the other package
299 # suites: Chromium gets too little CPU and diff workers miss their 10s start budget.
300 test_web:
301 name: Release web tests
302 needs: [preflight]
303 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
304 runs-on: blacksmith-8vcpu-ubuntu-2404
305 timeout-minutes: 10
306 steps:
307 - name: Checkout
308 uses: actions/checkout@v6
309 with:
310 ref: ${{ needs.preflight.outputs.ref }}
311 sparse-checkout: |
312 /*
313 !/.repos/
314 sparse-checkout-cone-mode: false
315
316 - name: Setup dependencies
317 uses: ./.github/actions/setup-ci-deps
318 with:
319 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
320
321 - name: Resolve Playwright version
322 id: playwright_version
323 run: echo "version=$(node -p "require('./apps/web/node_modules/playwright/package.json').version")" >> "$GITHUB_OUTPUT"
324
325 - name: Cache Chromium
326 id: chromium_cache
327 uses: actions/cache@v6
328 with:
329 path: ~/.cache/ms-playwright
330 key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
331
332 - name: Install Chromium for web browser tests
333 if: steps.chromium_cache.outputs.cache-hit != 'true'
334 run: node apps/web/node_modules/playwright/cli.js install --only-shell chromium
335
336 - name: Install missing Chromium system dependencies
337 run: |
338 browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
339 test -n "$browser"
340 if ldd "$browser" | grep '=> not found'; then
341 node apps/web/node_modules/playwright/cli.js install-deps chromium
342 fi
343
344 - name: Test
345 run: vp run --filter @t3tools/web test
346
347 # Browser tests run source modules; this boots the production chunk graph.
348 - name: Boot the built web client
349 run: |
350 vp run --filter @t3tools/web build
351 node apps/web/scripts/verify-built-boot.ts
352
353 # Server test files run one at a time, so more small runners beat fewer big ones.
354 test_server:
355 name: Release server tests ${{ matrix.shard }}
356 needs: [preflight]
357 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
358 runs-on: blacksmith-4vcpu-ubuntu-2404
359 timeout-minutes: 10
360 strategy:
361 fail-fast: false
362 matrix:
363 shard: [1, 2, 3, 4, 5, 6, 7, 8]
364 steps:
365 - name: Checkout
366 uses: actions/checkout@v6
367 with:
368 ref: ${{ needs.preflight.outputs.ref }}
369 sparse-checkout: |
370 /*
371 !/.repos/
372 sparse-checkout-cone-mode: false
373
374 - name: Setup dependencies
375 uses: ./.github/actions/setup-ci-deps
376 with:
377 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
378
379 # No Electron setup here: `t3` (apps/server) has no Electron dependency
380 # and none of its tests touch the runtime. Only the non-server `test`
381 # job, which covers @t3tools/desktop, needs the download.
382 - name: Install Chromium for server browser integration tests
383 run: node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium
384
385 - name: Test
386 run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
387
388 relay_public_config:
389 name: Resolve T3 Connect public config
390 # Consumes only the release commit, not preflight's resolved version, so it
391 # runs alongside preflight instead of after it. The condition mirrors preflight's.
392 needs: [resolve_commit]
393 if: |
394 needs.resolve_commit.result == 'success' &&
395 (github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
396 runs-on: blacksmith-8vcpu-ubuntu-2404
397 timeout-minutes: 5
398 # Previews build any branch, but production admits only main and v* tags.
399 # The empty name runs previews with no environment, so their Clerk and relay
400 # ids come from .env.example. Everything else matches nightly: the tracing
401 # read below needs only repository-level Cloudflare credentials.
402 environment:
403 name: ${{ inputs.channel != 'preview' && 'production' || '' }}
404 outputs:
405 clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
406 clerk_jwt_template: ${{ steps.public_config.outputs.clerk_jwt_template }}
407 clerk_cli_oauth_client_id: ${{ steps.public_config.outputs.clerk_cli_oauth_client_id }}
408 relay_url: ${{ steps.public_config.outputs.relay_url }}
409 env:
410 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
411 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
412 RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
413 RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
414 CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
415 CLERK_JWT_TEMPLATE: ${{ vars.CLERK_JWT_TEMPLATE }}
416 CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.CLERK_CLI_OAUTH_CLIENT_ID }}
417 steps:
418 - name: Checkout
419 uses: actions/checkout@v6
420 with:
421 ref: ${{ needs.resolve_commit.outputs.ref }}
422 sparse-checkout: |
423 /*
424 !/.repos/
425 sparse-checkout-cone-mode: false
426
427 - name: Setup dependencies
428 uses: ./.github/actions/setup-ci-deps
429 with:
430 install-args: --filter=t3code-relay...
431
432 # The deployed stack's outputs, read from Alchemy's state store without
433 # planning or applying. Select the backend explicitly to avoid loading
434 # the stack's unrelated provider credentials; suppress informational logs
435 # and strip the credential-refresh progress prefix before parsing JSON.
436 # Redacted values are persisted as
437 # {"__redacted__": "<value>"}; the token is masked before it is written.
438 - name: Read production relay tracing config
439 shell: bash
440 working-directory: infra/relay
441 run: |
442 set -euo pipefail
443 output="$(npx alchemy state read T3CodeRelay/prod/output --backend cloudflare --log-level error --no-input | sed -n '/^{/,$p')"
444 field() {
445 jq -er --arg key "$1" '.[$key] | if type == "object" then .__redacted__ else . end | select(. != null and . != "")' <<<"$output" \
446 || { echo "Relay stack output is missing $1" >&2; exit 1; }
447 }
448 url="$(field clientTracingUrl)"
449 dataset="$(field clientTracingDataset)"
450 token="$(field clientTracingToken)"
451 echo "::add-mask::$token"
452 {
453 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=$url"
454 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=$dataset"
455 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=$token"
456 } > "$RUNNER_TEMP/relay-client-tracing.env"
457
458 - name: Upload relay client tracing config
459 uses: actions/upload-artifact@v7
460 with:
461 name: relay-client-tracing-config
462 path: ${{ runner.temp }}/relay-client-tracing.env
463 if-no-files-found: error
464 retention-days: 1
465
466 - id: public_config
467 name: Resolve production relay public config
468 shell: bash
469 env:
470 PREVIEW: ${{ inputs.channel == 'preview' }}
471 run: |
472 set -euo pipefail
473
474 if [[ "$PREVIEW" == "true" ]]; then
475 env_example() { sed -n "s|^T3CODE_$1=||p" .env.example; }
476 CLERK_PUBLISHABLE_KEY="$(env_example CLERK_PUBLISHABLE_KEY)"
477 CLERK_JWT_TEMPLATE="$(env_example CLERK_JWT_TEMPLATE)"
478 CLERK_CLI_OAUTH_CLIENT_ID="$(env_example CLERK_CLI_OAUTH_CLIENT_ID)"
479 RELAY_DOMAIN="$(sed -n 's|^T3CODE_RELAY_URL=https://||p' .env.example)"
480 fi
481
482 relay_domain="${RELAY_DOMAIN:-}"
483 if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
484 relay_domain="relay.$RELAY_API_ZONE_NAME"
485 fi
486 required=(
487 relay_domain
488 CLERK_PUBLISHABLE_KEY
489 CLERK_JWT_TEMPLATE
490 CLERK_CLI_OAUTH_CLIENT_ID
491 )
492 missing=()
493 for name in "${required[@]}"; do
494 if [[ -z "${!name:-}" ]]; then
495 missing+=("$name")
496 fi
497 done
498 if (( ${#missing[@]} > 0 )); then
499 printf 'Missing required relay deployment configuration: %s\n' "${missing[*]}" >&2
500 exit 1
501 fi
502
503 echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
504 echo "clerk_jwt_template=$CLERK_JWT_TEMPLATE" >> "$GITHUB_OUTPUT"
505 echo "clerk_cli_oauth_client_id=$CLERK_CLI_OAUTH_CLIENT_ID" >> "$GITHUB_OUTPUT"
506 echo "relay_url=https://$relay_domain" >> "$GITHUB_OUTPUT"
507
508 # The platform-independent JS (server bundle, web client, Electron main) is
509 # built exactly once here and handed to every platform job as `js-bundle`.
510 # The relay/Clerk values are baked into the bundle, so they belong to this
511 # job rather than to the packaging jobs.
512 build_bundle:
513 name: Build JS bundle
514 # Same gating as relay_public_config: only the release commit is needed, so
515 # this runs alongside preflight. See the condition comment there.
516 needs: [preflight, relay_public_config]
517 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
518 runs-on: blacksmith-32vcpu-ubuntu-2404
519 timeout-minutes: 30
520 env:
521 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
522 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
523 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
524 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
525 steps:
526 - name: Checkout
527 uses: actions/checkout@v6
528 with:
529 ref: ${{ needs.preflight.outputs.ref }}
530 sparse-checkout: |
531 /*
532 !/.repos/
533 sparse-checkout-cone-mode: false
534
535 # pnpm checks the lockfile and policy before reusing this result. A missing
536 # artifact leaves the cache empty, so installation runs the checks again.
537 - name: Download dependency verification
538 continue-on-error: true
539 uses: actions/download-artifact@v8
540 with:
541 name: release-dependency-verification
542 path: ${{ runner.temp }}/pnpm-metadata
543
544 - name: Setup dependencies
545 uses: ./.github/actions/setup-ci-deps
546 with:
547 install-args: --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts...
548 env:
549 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
550
551 - name: Download relay client tracing config
552 uses: actions/download-artifact@v8
553 with:
554 name: relay-client-tracing-config
555 path: ${{ runner.temp }}/relay-client-tracing
556
557 - name: Load relay client tracing config
558 shell: bash
559 run: |
560 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
561 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
562 echo "::add-mask::$tracing_token"
563 cat "$config_path" >> "$GITHUB_ENV"
564
565 - name: Align package versions to release version
566 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
567
568 - uses: ./.github/actions/setup-apt-mirrors
569
570 # @t3tools/desktop#build compiles the Linux browser secret helper on a
571 # Linux host before packing, and that needs libsecret headers.
572 - name: Install browser secret helper build libraries
573 run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
574
575 # Runs t3#build (which depends on @t3tools/web#build) and
576 # @t3tools/desktop#build, so apps/server/dist holds the server bundle
577 # plus the web client and apps/desktop/dist-electron the Electron main.
578 # The release channel is already stable, nightly, or preview. Builds in
579 # other repositories report "dev" telemetry.
580 - name: Build JS bundle
581 env:
582 T3CODE_TELEMETRY_CHANNEL: ${{ github.repository == 'pingdotgg/t3code' && needs.preflight.outputs.release_channel || 'dev' }}
583 run: vp run build:desktop
584
585 # Two paths under apps/ so the artifact root is apps/; consumers download
586 # into `apps` to restore both at their original locations.
587 - name: Upload JS bundle
588 uses: actions/upload-artifact@v7
589 with:
590 name: js-bundle
591 path: |
592 apps/server/dist
593 apps/desktop/dist-electron
594 if-no-files-found: error
595 retention-days: 1
596
597 # One job per platform and architecture (see release-desktop.yml), each
598 # gated only on the JS bundle. Windows targets build on Linux and run their
599 # native checks on a Windows runner of their own architecture.
600 # The Windows jobs also embed the same-arch Linux CLI archive as the WSL
601 # runtime; they wait for that artifact partway through instead of for the
602 # whole Linux job. Every job builds the desktop app; all but macOS x64 also
603 # build the CLI archive for their platform, so a target either ships fully or
604 # not at all.
605 desktop_mac_arm64:
606 name: Desktop macOS arm64
607 needs: [preflight, relay_public_config, build_bundle]
608 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
609 uses: ./.github/workflows/release-desktop.yml
610 secrets: inherit
611 with:
612 version: ${{ needs.preflight.outputs.version }}
613 ref: ${{ needs.preflight.outputs.ref }}
614 release_channel: ${{ needs.preflight.outputs.release_channel }}
615 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
616 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
617 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
618 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
619 label: macOS arm64
620 runner: blacksmith-12vcpu-macos-26
621 platform: mac
622 target: dmg
623 arch: arm64
624 rust_target: aarch64-apple-darwin
625 resource_key: darwin-arm64
626 cli_archive: true
627 launch_check: true
628
629 desktop_mac_x64:
630 name: Desktop macOS x64
631 needs: [preflight, relay_public_config, build_bundle]
632 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
633 uses: ./.github/workflows/release-desktop.yml
634 secrets: inherit
635 with:
636 version: ${{ needs.preflight.outputs.version }}
637 ref: ${{ needs.preflight.outputs.ref }}
638 release_channel: ${{ needs.preflight.outputs.release_channel }}
639 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
640 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
641 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
642 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
643 label: macOS x64
644 runner: blacksmith-12vcpu-macos-26
645 platform: mac
646 target: dmg
647 arch: x64
648 rust_target: x86_64-apple-darwin
649 resource_key: darwin-x64
650 # No CLI archive: Node single-executables are unsupported on x64 macOS
651 # (the SEA docs list macOS as arm64 only) and the built binary segfaults
652 # on start. The x64 desktop app is Electron and unaffected.
653 cli_archive: false
654
655 desktop_linux_x64:
656 name: Desktop Linux x64
657 needs: [preflight, relay_public_config, build_bundle]
658 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
659 uses: ./.github/workflows/release-desktop.yml
660 secrets: inherit
661 with:
662 version: ${{ needs.preflight.outputs.version }}
663 ref: ${{ needs.preflight.outputs.ref }}
664 release_channel: ${{ needs.preflight.outputs.release_channel }}
665 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
666 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
667 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
668 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
669 label: Linux x64
670 runner: blacksmith-32vcpu-ubuntu-2404
671 platform: linux
672 target: AppImage
673 arch: x64
674 rust_target: x86_64-unknown-linux-gnu
675 resource_key: linux-x64
676 cli_archive: true
677 launch_check: true
678
679 # node-pty has no Linux prebuild and compiles from source, so the arm64 app
680 # and archive are built on arm64 hardware rather than cross-built.
681 desktop_linux_arm64:
682 name: Desktop Linux arm64
683 needs: [preflight, relay_public_config, build_bundle]
684 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
685 uses: ./.github/workflows/release-desktop.yml
686 secrets: inherit
687 with:
688 version: ${{ needs.preflight.outputs.version }}
689 ref: ${{ needs.preflight.outputs.ref }}
690 release_channel: ${{ needs.preflight.outputs.release_channel }}
691 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
692 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
693 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
694 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
695 label: Linux arm64
696 runner: blacksmith-16vcpu-ubuntu-2404-arm
697 platform: linux
698 target: AppImage
699 arch: arm64
700 rust_target: aarch64-unknown-linux-gnu
701 resource_key: linux-arm64
702 cli_archive: true
703
704 # The Windows jobs start with the other platforms and wait for the same-arch
705 # Linux CLI archive after their other setup. Packaging is mostly CPU and
706 # small-file work, which Linux runners do faster than Windows ones, so both
707 # Windows targets build and sign on Linux and only the native checks run on
708 # Windows.
709 desktop_win_x64:
710 name: Desktop Windows x64
711 needs: [preflight, relay_public_config, build_bundle]
712 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
713 uses: ./.github/workflows/release-desktop.yml
714 secrets: inherit
715 with:
716 version: ${{ needs.preflight.outputs.version }}
717 ref: ${{ needs.preflight.outputs.ref }}
718 release_channel: ${{ needs.preflight.outputs.release_channel }}
719 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
720 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
721 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
722 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
723 label: Windows x64
724 runner: blacksmith-16vcpu-ubuntu-2404
725 verify_runner: windows-2025
726 platform: win
727 target: nsis
728 arch: x64
729 rust_target: x86_64-pc-windows-msvc
730 resource_key: win32-x64
731 cli_archive: true
732
733 desktop_win_arm64:
734 name: Desktop Windows arm64
735 needs: [preflight, relay_public_config, build_bundle]
736 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
737 uses: ./.github/workflows/release-desktop.yml
738 secrets: inherit
739 with:
740 version: ${{ needs.preflight.outputs.version }}
741 ref: ${{ needs.preflight.outputs.ref }}
742 release_channel: ${{ needs.preflight.outputs.release_channel }}
743 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
744 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
745 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
746 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
747 label: Windows arm64
748 runner: blacksmith-16vcpu-ubuntu-2404
749 verify_runner: windows-11-arm
750 platform: win
751 target: nsis
752 arch: arm64
753 rust_target: aarch64-pc-windows-msvc
754 resource_key: win32-arm64
755 cli_archive: true
756
757 release:
758 name: Publish GitHub Release
759 needs:
760 [
761 preflight,
762 relay_public_config,
763 quality,
764 test,
765 test_web,
766 test_server,
767 desktop_mac_arm64,
768 desktop_mac_x64,
769 desktop_linux_x64,
770 desktop_linux_arm64,
771 desktop_win_x64,
772 desktop_win_arm64,
773 ]
774 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.quality.result == 'success' && needs.test.result == 'success' && needs.test_web.result == 'success' && needs.test_server.result == 'success' && needs.desktop_mac_arm64.result == 'success' && needs.desktop_mac_x64.result == 'success' && needs.desktop_linux_x64.result == 'success' && needs.desktop_linux_arm64.result == 'success' && needs.desktop_win_x64.result == 'success' && needs.desktop_win_arm64.result == 'success' }}
775 runs-on: blacksmith-8vcpu-ubuntu-2404
776 timeout-minutes: 30
777 permissions:
778 contents: write
779 # Release notes read PR bodies and authors.
780 pull-requests: read
781 steps:
782 - name: Checkout
783 uses: actions/checkout@v6
784 with:
785 ref: ${{ needs.preflight.outputs.ref }}
786 # Release notes need history back to the previous tag, not file contents.
787 fetch-depth: 0
788 filter: blob:none
789 sparse-checkout: |
790 /*
791 !/.repos/
792 sparse-checkout-cone-mode: false
793
794 - name: Setup dependencies
795 uses: ./.github/actions/setup-ci-deps
796 with:
797 install-args: --filter=@t3tools/scripts...
798
799 - name: Download all desktop artifacts
800 uses: actions/download-artifact@v8
801 with:
802 pattern: desktop-*
803 merge-multiple: true
804 path: release-assets
805
806 - name: Download all CLI archives
807 uses: actions/download-artifact@v8
808 with:
809 pattern: cli-*
810 merge-multiple: true
811 path: release-assets
812
813 - name: Download internal Android APK for Nightly
814 if: needs.preflight.outputs.release_channel == 'nightly'
815 continue-on-error: true
816 env:
817 GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
818 PACKAGE_NAME: com.t3tools.t3code
819 APK_OUTPUT_DIR: release-assets
820 run: |
821 if [ -n "$GOOGLE_PLAY_SERVICE_ACCOUNT_JSON" ]; then
822 node .github/scripts/mirror-play-apk.cjs
823 fi
824
825 # Installers verify archives against this file, so it is written from the
826 # signed bytes that get uploaded, never from an earlier stage.
827 - name: Write CLI archive checksums
828 shell: bash
829 run: |
830 set -euo pipefail
831 cd release-assets
832 shopt -s nullglob
833 archives=(t3-*.tar.gz t3-*.zip)
834 if [[ ${#archives[@]} -eq 0 ]]; then
835 echo "No CLI archives were produced." >&2
836 exit 1
837 fi
838 sha256sum "${archives[@]}" > SHA256SUMS
839 cat SHA256SUMS
840
841 # The desktop build omits the publish config for preview versions, so
842 # electron-builder emits no updater manifests for them. Refuse to publish
843 # if one shows up anyway: a `latest*.yml` or `nightly*.yml` on a preview
844 # release is what would let a stable or nightly install update onto it.
845 - name: Refuse updater metadata on preview releases
846 if: needs.preflight.outputs.release_channel == 'preview'
847 shell: bash
848 run: |
849 set -euo pipefail
850 shopt -s nullglob extglob
851 # builder-debug.yml is electron-builder's config dump, not a feed.
852 updater_files=(release-assets/!(builder-debug).yml release-assets/*.blockmap)
853 if [[ ${#updater_files[@]} -ne 0 ]]; then
854 printf 'Preview releases must not carry updater metadata, found: %s\n' "${updater_files[*]}" >&2
855 exit 1
856 fi
857
858 # electron-updater reads one manifest per platform and channel and picks
859 # the file entry whose name carries the running arch, so the per-arch
860 # manifests the build jobs wrote are merged back into that one file.
861 - name: Merge macOS updater manifests
862 if: needs.preflight.outputs.release_channel != 'preview'
863 run: |
864 shopt -s nullglob
865 for x64_manifest in release-assets/*-mac-x64.yml; do
866 arm64_manifest="${x64_manifest%-x64.yml}.yml"
867 if [[ -f "$arm64_manifest" ]]; then
868 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
869 rm -f "$x64_manifest"
870 fi
871 done
872
873 - name: Merge Windows updater manifests
874 if: needs.preflight.outputs.release_channel != 'preview'
875 run: |
876 shopt -s nullglob
877 for x64_manifest in release-assets/*-win-x64.yml; do
878 arm64_manifest="${x64_manifest%-x64.yml}-arm64.yml"
879 merged_manifest="${x64_manifest%-win-x64.yml}.yml"
880 if [[ -f "$arm64_manifest" ]]; then
881 node scripts/merge-update-manifests.ts --platform win "$x64_manifest" "$arm64_manifest" "$merged_manifest"
882 rm -f "$x64_manifest" "$arm64_manifest"
883 else
884 mv "$x64_manifest" "$merged_manifest"
885 fi
886 done
887
888 # Updater manifests and blockmaps are what electron-updater consumes.
889 # They are only listed for channels an updater is meant to follow.
890 - id: release_files
891 name: Resolve release asset list
892 shell: bash
893 run: |
894 {
895 echo 'files<<EOF'
896 echo 'release-assets/*.dmg'
897 echo 'release-assets/*.zip'
898 echo 'release-assets/*.AppImage'
899 echo 'release-assets/*.deb'
900 echo 'release-assets/*.exe'
901 if [[ "${{ needs.preflight.outputs.release_channel }}" != "preview" ]]; then
902 echo 'release-assets/*.blockmap'
903 echo 'release-assets/*.yml'
904 fi
905 echo 'release-assets/*.tar.gz'
906 # Only list APKs when Play has a processed internal build available.
907 for apk in release-assets/*.apk; do
908 [[ -f "$apk" ]] && echo "$apk"
909 done
910 echo 'release-assets/SHA256SUMS'
911 echo 'EOF'
912 } >> "$GITHUB_OUTPUT"
913
914 # A short model summary over GitHub's full list. Without a notes file, the
915 # release falls back to GitHub's generated notes.
916 - name: Write release notes
917 if: needs.preflight.outputs.release_channel != 'preview' && needs.preflight.outputs.previous_tag != ''
918 continue-on-error: true
919 timeout-minutes: 5
920 env:
921 GH_TOKEN: ${{ github.token }}
922 OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
923 run: |
924 node scripts/generate-release-notes.ts \
925 --repository "${{ github.repository }}" \
926 --tag "${{ needs.preflight.outputs.tag }}" \
927 --ref "${{ needs.preflight.outputs.ref }}" \
928 --previous-tag "${{ needs.preflight.outputs.previous_tag }}" \
929 --version "${{ needs.preflight.outputs.version }}" \
930 --output release-notes.md
931 if [[ -f release-notes.md ]]; then
932 cat release-notes.md >> "$GITHUB_STEP_SUMMARY"
933 fi
934
935 # A preview release gets a warning instead of generated notes. Generated
936 # notes would list every commit since the previous preview, which is
937 # unmerged branch history no one should read as a changelog, and would
938 # make the release look like any other build to someone browsing the
939 # releases page.
940 - name: Write preview release notes
941 if: needs.preflight.outputs.release_channel == 'preview'
942 shell: bash
943 run: |
944 cat > release-notes.md <<'EOF'
945 > [!WARNING]
946 > **This is a preview build. Do not install it unless you know exactly why you are here.**
947 >
948 > Preview builds are cut by maintainers from unreleased branches to exercise the release pipeline. They can be broken, receive no fixes, are never offered as updates, and are not supported. If you want T3 Code, install the [latest release](https://github.com/pingdotgg/t3code/releases/latest) or a nightly instead.
949
950 Built from `${{ needs.preflight.outputs.ref }}`.
951 EOF
952
953 - name: Publish release
954 if: needs.preflight.outputs.previous_tag != ''
955 uses: softprops/action-gh-release@v3
956 with:
957 tag_name: ${{ needs.preflight.outputs.tag }}
958 target_commitish: ${{ needs.preflight.outputs.ref }}
959 name: ${{ needs.preflight.outputs.release_name }}
960 generate_release_notes: ${{ hashFiles('release-notes.md') == '' }}
961 body_path: ${{ hashFiles('release-notes.md') != '' && 'release-notes.md' || '' }}
962 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
963 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
964 draft: ${{ needs.preflight.outputs.is_prerelease }}
965 make_latest: ${{ needs.preflight.outputs.make_latest }}
966 files: ${{ steps.release_files.outputs.files }}
967 fail_on_unmatched_files: true
968 token: ${{ github.token }}
969
970 - name: Publish first release
971 if: needs.preflight.outputs.previous_tag == ''
972 uses: softprops/action-gh-release@v3
973 with:
974 tag_name: ${{ needs.preflight.outputs.tag }}
975 target_commitish: ${{ needs.preflight.outputs.ref }}
976 name: ${{ needs.preflight.outputs.release_name }}
977 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
978 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
979 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
980 draft: ${{ needs.preflight.outputs.is_prerelease }}
981 make_latest: ${{ needs.preflight.outputs.make_latest }}
982 files: ${{ steps.release_files.outputs.files }}
983 fail_on_unmatched_files: true
984 token: ${{ github.token }}
985
986 # The action keeps a stable release a draft until its assets finish uploading, but publishes a
987 # prerelease first. Desktop clients update connected servers from the CLI archives as soon as
988 # they see the release, so a prerelease also goes public only once every asset is attached.
989 - name: Publish prerelease
990 if: needs.preflight.outputs.is_prerelease == 'true'
991 env:
992 GH_TOKEN: ${{ github.token }}
993 GH_REPO: ${{ github.repository }}
994 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
995 run: gh release edit "$RELEASE_TAG" --draft=false
996
997 # The `t3` npm package is a launcher that downloads this version's CLI
998 # archive from the GitHub Release, so it publishes only once that release
999 # exists. Preview publishes too, under the `preview` dist-tag, which
1000 # nothing resolves unless asked for by name.
1001 publish_cli:
1002 name: Publish CLI to npm
1003 needs: [preflight, release]
1004 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
1005 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
1006 timeout-minutes: 15
1007 permissions:
1008 contents: read
1009 id-token: write
1010 steps:
1011 - name: Checkout
1012 uses: actions/checkout@v6
1013 with:
1014 ref: ${{ needs.preflight.outputs.ref }}
1015 sparse-checkout: |
1016 /*
1017 !/.repos/
1018 sparse-checkout-cone-mode: false
1019
1020 - name: Setup dependencies
1021 uses: ./.github/actions/setup-ci-deps
1022 with:
1023 install-args: --filter=t3... --filter=@t3tools/scripts...
1024
1025 - name: Build the npm launcher
1026 run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages
1027
1028 - name: Publish the npm launcher
1029 run: |
1030 if ! node apps/server/scripts/cli.ts publish --packages-dir npm-packages --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --provenance --verbose; then
1031 echo "::error::npm publish failed. Make sure package t3 has a trusted publisher registered for .github/workflows/release.yml (see docs/operations/release.md)." >&2
1032 exit 1
1033 fi
1034
1035 publish_aur:
1036 name: Publish AUR package
1037 needs: [preflight, release]
1038 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1039 uses: ./.github/workflows/publish-aur.yml
1040 with:
1041 release_tag: ${{ needs.preflight.outputs.tag }}
1042 secrets:
1043 AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
1044
1045 # Vercel builds the hosted web app while the desktop jobs run. `--skip-domain`
1046 # keeps the custom domains (the channel and router domains) on the previous
1047 # deployment until deploy_web aliases them, after the GitHub Release. It does
1048 # still move the project's own *.vercel.app production hostname at build time.
1049 # That hostname sits behind Vercel SSO and is not a user channel, so the
1050 # npm-before-client order in docs/operations/release.md holds for users.
1051 build_web:
1052 name: Build hosted web app
1053 needs: [preflight, relay_public_config]
1054 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1055 runs-on: blacksmith-8vcpu-ubuntu-2404
1056 timeout-minutes: 10
1057 outputs:
1058 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1059 env:
1060 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
1061 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
1062 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
1063 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
1064 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1065 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1066 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1067 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1068 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1069 steps:
1070 - name: Checkout
1071 uses: actions/checkout@v6
1072 with:
1073 ref: ${{ needs.preflight.outputs.ref }}
1074 sparse-checkout: |
1075 /*
1076 !/.repos/
1077 sparse-checkout-cone-mode: false
1078
1079 - name: Setup dependencies
1080 uses: ./.github/actions/setup-ci-deps
1081 with:
1082 install-args: --filter=@t3tools/scripts... --filter=@t3tools/web...
1083
1084 - name: Download relay client tracing config
1085 uses: actions/download-artifact@v8
1086 with:
1087 name: relay-client-tracing-config
1088 path: ${{ runner.temp }}/relay-client-tracing
1089
1090 - name: Load relay client tracing config
1091 shell: bash
1092 run: |
1093 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
1094 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
1095 echo "::add-mask::$tracing_token"
1096 cat "$config_path" >> "$GITHUB_ENV"
1097
1098 - name: Align package versions to release version
1099 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
1100
1101 - name: Refresh release lockfile
1102 run: vp install --lockfile-only --ignore-scripts
1103
1104 - id: deploy
1105 name: Build staged deployment
1106 shell: bash
1107 run: |
1108 set -euo pipefail
1109
1110 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
1111 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
1112 exit 1
1113 fi
1114
1115 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1116 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1117 channel_name="latest"
1118 else
1119 channel_name="nightly"
1120 fi
1121
1122 echo "Building hosted web app for $channel_name channel."
1123 deployment_output="$(
1124 vp dlx vercel@53.1.1 deploy \
1125 --archive=tgz \
1126 --prod \
1127 --skip-domain \
1128 --yes \
1129 --token "$VERCEL_TOKEN" \
1130 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}" \
1131 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
1132 --build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \
1133 --build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \
1134 --build-env "T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=${T3CODE_CLERK_CLI_OAUTH_CLIENT_ID:-}" \
1135 --build-env "T3CODE_RELAY_URL=${T3CODE_RELAY_URL:-}" \
1136 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=${T3CODE_RELAY_CLIENT_OTLP_TRACES_URL:-}" \
1137 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=${T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET:-}" \
1138 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=${T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN:-}" \
1139 --build-env "VITE_HOSTED_APP_URL=$router_url" \
1140 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
1141 )"
1142 printf '%s\n' "$deployment_output"
1143 # Vercel can print lockfile warnings to stdout before the deployment URL.
1144 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1145 if [[ "$deployment_url" == *$'\n'* ]]; then
1146 echo "Vercel returned multiple deployment URLs." >&2
1147 exit 1
1148 fi
1149 echo "Staged $deployment_url."
1150 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1151
1152 deploy_web:
1153 name: Deploy hosted web app
1154 needs: [preflight, build_web, release, publish_cli]
1155 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_web.result == 'success' && needs.release.result == 'success' && needs.publish_cli.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1156 runs-on: blacksmith-2vcpu-ubuntu-2404
1157 timeout-minutes: 10
1158 env:
1159 DEPLOYMENT_URL: ${{ needs.build_web.outputs.deployment_url }}
1160 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1161 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1162 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1163 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1164 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
1165 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
1166 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1167 steps:
1168 - name: Checkout
1169 uses: actions/checkout@v6
1170 with:
1171 ref: ${{ needs.preflight.outputs.ref }}
1172 sparse-checkout: |
1173 /*
1174 !/.repos/
1175 sparse-checkout-cone-mode: false
1176
1177 - name: Setup Vite+
1178 uses: ./.github/actions/setup-ci-deps
1179 with:
1180 install: false
1181
1182 - name: Alias channel
1183 shell: bash
1184 run: |
1185 set -euo pipefail
1186
1187 if [[ -z "$DEPLOYMENT_URL" ]]; then
1188 echo "Build hosted web app did not report a deployment URL." >&2
1189 exit 1
1190 fi
1191
1192 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1193 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
1194 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
1195 router_domain="${router_url#http://}"
1196 router_domain="${router_domain#https://}"
1197 router_domain="${router_domain%%/*}"
1198
1199 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1200 channel_domain="$latest_domain"
1201 channel_name="latest"
1202 else
1203 channel_domain="$nightly_domain"
1204 channel_name="nightly"
1205 fi
1206
1207 vercel_scope_args=(--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}")
1208
1209 echo "Aliasing $DEPLOYMENT_URL to $channel_domain."
1210 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$channel_domain" \
1211 --token "$VERCEL_TOKEN" \
1212 "${vercel_scope_args[@]}"
1213
1214 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
1215 echo "Aliasing $DEPLOYMENT_URL to router domain $router_domain."
1216 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$router_domain" \
1217 --token "$VERCEL_TOKEN" \
1218 "${vercel_scope_args[@]}"
1219 fi
1220
1221 # Same split as the web app: build a production deployment early, then
1222 # promote it to t3.codes once the release it links to exists. As above, the
1223 # project's own *.vercel.app hostname moves at build time.
1224 build_marketing:
1225 name: Build marketing site
1226 needs: [preflight]
1227 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1228 runs-on: blacksmith-8vcpu-ubuntu-2404
1229 timeout-minutes: 10
1230 outputs:
1231 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1232 project_id: ${{ steps.deploy.outputs.project_id }}
1233 env:
1234 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1235 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1236 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1237 steps:
1238 - name: Checkout
1239 uses: actions/checkout@v6
1240 with:
1241 ref: ${{ needs.preflight.outputs.ref }}
1242 sparse-checkout: |
1243 /*
1244 !/.repos/
1245 sparse-checkout-cone-mode: false
1246
1247 - name: Setup dependencies
1248 uses: ./.github/actions/setup-ci-deps
1249 with:
1250 install-args: --filter=@t3tools/marketing...
1251
1252 - id: deploy
1253 name: Build staged deployment
1254 shell: bash
1255 run: |
1256 set -euo pipefail
1257
1258 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" ]]; then
1259 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID." >&2
1260 exit 1
1261 fi
1262
1263 VERCEL_PROJECT_ID="$(
1264 curl --fail --silent --show-error \
1265 --header "Authorization: Bearer $VERCEL_TOKEN" \
1266 "https://api.vercel.com/v9/projects/t3code-marketing?teamId=$VERCEL_ORG_ID" \
1267 | jq --exit-status --raw-output '.id'
1268 )"
1269 export VERCEL_PROJECT_ID
1270
1271 deployment_output="$(
1272 vp dlx vercel@53.1.1 deploy \
1273 --archive=tgz \
1274 --prod \
1275 --skip-domain \
1276 --yes \
1277 --token "$VERCEL_TOKEN" \
1278 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1279 )"
1280 printf '%s\n' "$deployment_output"
1281 # Vercel can print lockfile warnings to stdout before the deployment URL.
1282 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1283 if [[ "$deployment_url" == *$'\n'* ]]; then
1284 echo "Vercel returned multiple deployment URLs." >&2
1285 exit 1
1286 fi
1287 echo "Staged $deployment_url."
1288 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1289 echo "project_id=$VERCEL_PROJECT_ID" >> "$GITHUB_OUTPUT"
1290
1291 deploy_marketing:
1292 name: Deploy marketing site
1293 needs: [preflight, build_marketing, release]
1294 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_marketing.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1295 runs-on: blacksmith-2vcpu-ubuntu-2404
1296 timeout-minutes: 10
1297 env:
1298 DEPLOYMENT_URL: ${{ needs.build_marketing.outputs.deployment_url }}
1299 VERCEL_PROJECT_ID: ${{ needs.build_marketing.outputs.project_id }}
1300 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1301 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1302 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1303 steps:
1304 - name: Checkout
1305 uses: actions/checkout@v6
1306 with:
1307 ref: ${{ needs.preflight.outputs.ref }}
1308 sparse-checkout: |
1309 /*
1310 !/.repos/
1311 sparse-checkout-cone-mode: false
1312
1313 - name: Setup Vite+
1314 uses: ./.github/actions/setup-ci-deps
1315 with:
1316 install: false
1317
1318 - name: Promote marketing site
1319 shell: bash
1320 run: |
1321 set -euo pipefail
1322
1323 if [[ -z "$DEPLOYMENT_URL" ]]; then
1324 echo "Build marketing site did not report a deployment URL." >&2
1325 exit 1
1326 fi
1327
1328 echo "Promoting $DEPLOYMENT_URL."
1329 vp dlx vercel@53.1.1 promote "$DEPLOYMENT_URL" \
1330 --yes \
1331 --token "$VERCEL_TOKEN" \
1332 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1333
1334 finalize:
1335 name: Finalize release
1336 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
1337 needs: [preflight, release]
1338 runs-on: blacksmith-8vcpu-ubuntu-2404
1339 timeout-minutes: 10
1340 steps:
1341 - id: app_token
1342 name: Mint release app token
1343 uses: actions/create-github-app-token@v2
1344 with:
1345 app-id: ${{ secrets.RELEASE_APP_ID }}
1346 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
1347 owner: ${{ github.repository_owner }}
1348
1349 - name: Checkout
1350 uses: actions/checkout@v6
1351 with:
1352 ref: main
1353 fetch-depth: 0
1354 token: ${{ steps.app_token.outputs.token }}
1355 persist-credentials: true
1356 sparse-checkout: |
1357 /*
1358 !/.repos/
1359 sparse-checkout-cone-mode: false
1360
1361 - id: app_bot
1362 name: Resolve GitHub App bot identity
1363 env:
1364 GH_TOKEN: ${{ steps.app_token.outputs.token }}
1365 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
1366 run: |
1367 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
1368 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
1369 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
1370
1371 - name: Setup dependencies
1372 uses: ./.github/actions/setup-ci-deps
1373 with:
1374 install-args: --filter=@t3tools/scripts... --filter=@t3tools/oxlint-plugin-t3code...
1375
1376 - id: update_versions
1377 name: Update version strings
1378 env:
1379 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
1380 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
1381
1382 - name: Format package.json files
1383 if: steps.update_versions.outputs.changed == 'true'
1384 run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
1385
1386 - name: Refresh lockfile
1387 if: steps.update_versions.outputs.changed == 'true'
1388 run: vp install --lockfile-only --ignore-scripts
1389
1390 - name: Commit and push version bump
1391 if: steps.update_versions.outputs.changed == 'true'
1392 shell: bash
1393 env:
1394 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1395 run: |
1396 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml; then
1397 echo "No version changes to commit."
1398 exit 0
1399 fi
1400
1401 git config user.name "${{ steps.app_bot.outputs.name }}"
1402 git config user.email "${{ steps.app_bot.outputs.email }}"
1403
1404 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
1405 git commit --no-verify -m "chore(release): prepare $RELEASE_TAG"
1406 git push origin HEAD:main
1407
1408 announce_discord:
1409 name: Announce release on Discord
1410 if: |
1411 always() && !cancelled() &&
1412 needs.preflight.result == 'success' &&
1413 needs.preflight.outputs.release_channel != 'preview' &&
1414 needs.relay_public_config.result == 'success' &&
1415 needs.release.result == 'success' &&
1416 needs.deploy_web.result == 'success' &&
1417 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
1418 needs: [preflight, relay_public_config, release, deploy_web, finalize]
1419 runs-on: blacksmith-8vcpu-ubuntu-2404
1420 timeout-minutes: 10
1421 steps:
1422 - name: Checkout
1423 uses: actions/checkout@v6
1424 with:
1425 ref: ${{ needs.preflight.outputs.ref }}
1426 sparse-checkout: |
1427 /*
1428 !/.repos/
1429 sparse-checkout-cone-mode: false
1430
1431 - name: Setup dependencies
1432 uses: ./.github/actions/setup-ci-deps
1433 with:
1434 install-args: --filter=@t3tools/scripts...
1435
1436 - name: Read published release notes
1437 if: needs.preflight.outputs.is_prerelease == 'true'
1438 continue-on-error: true
1439 env:
1440 GH_TOKEN: ${{ github.token }}
1441 GH_REPO: ${{ github.repository }}
1442 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1443 RELEASE_CHANNEL: ${{ needs.preflight.outputs.release_channel }}
1444 run: |
1445 if [ "$RELEASE_CHANNEL" = 'nightly' ]; then
1446 if ! gh release view "$RELEASE_TAG" --json body --jq '.body // ""' > "$RUNNER_TEMP/discord-release-notes.md"; then
1447 : > "$RUNNER_TEMP/discord-release-notes.md"
1448 echo '::warning::Could not read published release notes; announcing without a changelog.'
1449 fi
1450 else
1451 : > "$RUNNER_TEMP/discord-release-notes.md"
1452 fi
1453
1454 - name: Announce prerelease on Discord
1455 if: needs.preflight.outputs.is_prerelease == 'true'
1456 continue-on-error: true
1457 env:
1458 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
1459 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1460 run: |
1461 node scripts/notify-discord-release.ts prerelease \
1462 --role-id "$DISCORD_MENTION_ROLE_ID" \
1463 --release-name "${{ needs.preflight.outputs.release_name }}" \
1464 --release-version "${{ needs.preflight.outputs.version }}" \
1465 --tag "${{ needs.preflight.outputs.tag }}" \
1466 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}" \
1467 --release-notes-file "$RUNNER_TEMP/discord-release-notes.md"
1468
1469 - name: Announce latest release on Discord
1470 if: needs.preflight.outputs.make_latest == 'true'
1471 continue-on-error: true
1472 env:
1473 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
1474 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1475 run: |
1476 node scripts/notify-discord-release.ts latest \
1477 --role-id "$DISCORD_MENTION_ROLE_ID" \
1478 --release-name "${{ needs.preflight.outputs.release_name }}" \
1479 --release-version "${{ needs.preflight.outputs.version }}" \
1480 --tag "${{ needs.preflight.outputs.tag }}" \
1481 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"