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

release.yml

1,467 lines61.5 KB

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 environment:
399 name: production
400 outputs:
401 clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
402 clerk_jwt_template: ${{ steps.public_config.outputs.clerk_jwt_template }}
403 clerk_cli_oauth_client_id: ${{ steps.public_config.outputs.clerk_cli_oauth_client_id }}
404 relay_url: ${{ steps.public_config.outputs.relay_url }}
405 env:
406 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
407 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
408 RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
409 RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
410 CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
411 CLERK_JWT_TEMPLATE: ${{ vars.CLERK_JWT_TEMPLATE }}
412 CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.CLERK_CLI_OAUTH_CLIENT_ID }}
413 steps:
414 - name: Checkout
415 uses: actions/checkout@v6
416 with:
417 ref: ${{ needs.resolve_commit.outputs.ref }}
418 sparse-checkout: |
419 /*
420 !/.repos/
421 sparse-checkout-cone-mode: false
422​
423 - name: Setup dependencies
424 uses: ./.github/actions/setup-ci-deps
425 with:
426 install-args: --filter=t3code-relay...
427​
428 # The deployed stack's outputs, read from Alchemy's state store without
429 # planning or applying. Select the backend explicitly to avoid loading
430 # the stack's unrelated provider credentials; suppress informational logs
431 # and strip the credential-refresh progress prefix before parsing JSON.
432 # Redacted values are persisted as
433 # {"__redacted__": "<value>"}; the token is masked before it is written.
434 - name: Read production relay tracing config
435 shell: bash
436 working-directory: infra/relay
437 run: |
438 set -euo pipefail
439 output="$(npx alchemy state read T3CodeRelay/prod/output --backend cloudflare --log-level error --no-input | sed -n '/^{/,$p')"
440 field() {
441 jq -er --arg key "$1" '.[$key] | if type == "object" then .__redacted__ else . end | select(. != null and . != "")' <<<"$output" \
442 || { echo "Relay stack output is missing $1" >&2; exit 1; }
443 }
444 url="$(field clientTracingUrl)"
445 dataset="$(field clientTracingDataset)"
446 token="$(field clientTracingToken)"
447 echo "::add-mask::$token"
448 {
449 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=$url"
450 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=$dataset"
451 echo "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=$token"
452 } > "$RUNNER_TEMP/relay-client-tracing.env"
453​
454 - name: Upload relay client tracing config
455 uses: actions/upload-artifact@v7
456 with:
457 name: relay-client-tracing-config
458 path: ${{ runner.temp }}/relay-client-tracing.env
459 if-no-files-found: error
460 retention-days: 1
461​
462 - id: public_config
463 name: Resolve production relay public config
464 shell: bash
465 run: |
466 set -euo pipefail
467​
468 relay_domain="${RELAY_DOMAIN:-}"
469 if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
470 relay_domain="relay.$RELAY_API_ZONE_NAME"
471 fi
472 required=(
473 relay_domain
474 CLERK_PUBLISHABLE_KEY
475 CLERK_JWT_TEMPLATE
476 CLERK_CLI_OAUTH_CLIENT_ID
477 )
478 missing=()
479 for name in "${required[@]}"; do
480 if [[ -z "${!name:-}" ]]; then
481 missing+=("$name")
482 fi
483 done
484 if (( ${#missing[@]} > 0 )); then
485 printf 'Missing required relay deployment configuration: %s\n' "${missing[*]}" >&2
486 exit 1
487 fi
488​
489 echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
490 echo "clerk_jwt_template=$CLERK_JWT_TEMPLATE" >> "$GITHUB_OUTPUT"
491 echo "clerk_cli_oauth_client_id=$CLERK_CLI_OAUTH_CLIENT_ID" >> "$GITHUB_OUTPUT"
492 echo "relay_url=https://$relay_domain" >> "$GITHUB_OUTPUT"
493​
494 # The platform-independent JS (server bundle, web client, Electron main) is
495 # built exactly once here and handed to every platform job as `js-bundle`.
496 # The relay/Clerk values are baked into the bundle, so they belong to this
497 # job rather than to the packaging jobs.
498 build_bundle:
499 name: Build JS bundle
500 # Same gating as relay_public_config: only the release commit is needed, so
501 # this runs alongside preflight. See the condition comment there.
502 needs: [preflight, relay_public_config]
503 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
504 runs-on: blacksmith-32vcpu-ubuntu-2404
505 timeout-minutes: 30
506 env:
507 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
508 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
509 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
510 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
511 steps:
512 - name: Checkout
513 uses: actions/checkout@v6
514 with:
515 ref: ${{ needs.preflight.outputs.ref }}
516 sparse-checkout: |
517 /*
518 !/.repos/
519 sparse-checkout-cone-mode: false
520​
521 # pnpm checks the lockfile and policy before reusing this result. A missing
522 # artifact leaves the cache empty, so installation runs the checks again.
523 - name: Download dependency verification
524 continue-on-error: true
525 uses: actions/download-artifact@v8
526 with:
527 name: release-dependency-verification
528 path: ${{ runner.temp }}/pnpm-metadata
529​
530 - name: Setup dependencies
531 uses: ./.github/actions/setup-ci-deps
532 with:
533 install-args: --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts...
534 env:
535 pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
536​
537 - name: Download relay client tracing config
538 uses: actions/download-artifact@v8
539 with:
540 name: relay-client-tracing-config
541 path: ${{ runner.temp }}/relay-client-tracing
542​
543 - name: Load relay client tracing config
544 shell: bash
545 run: |
546 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
547 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
548 echo "::add-mask::$tracing_token"
549 cat "$config_path" >> "$GITHUB_ENV"
550​
551 - name: Align package versions to release version
552 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
553​
554 - uses: ./.github/actions/setup-apt-mirrors
555​
556 # @t3tools/desktop#build compiles the Linux browser secret helper on a
557 # Linux host before packing, and that needs libsecret headers.
558 - name: Install browser secret helper build libraries
559 run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
560​
561 # Runs t3#build (which depends on @t3tools/web#build) and
562 # @t3tools/desktop#build, so apps/server/dist holds the server bundle
563 # plus the web client and apps/desktop/dist-electron the Electron main.
564 # The release channel is already stable, nightly, or preview. Builds in
565 # other repositories report "dev" telemetry.
566 - name: Build JS bundle
567 env:
568 T3CODE_TELEMETRY_CHANNEL: ${{ github.repository == 'pingdotgg/t3code' && needs.preflight.outputs.release_channel || 'dev' }}
569 run: vp run build:desktop
570​
571 # Two paths under apps/ so the artifact root is apps/; consumers download
572 # into `apps` to restore both at their original locations.
573 - name: Upload JS bundle
574 uses: actions/upload-artifact@v7
575 with:
576 name: js-bundle
577 path: |
578 apps/server/dist
579 apps/desktop/dist-electron
580 if-no-files-found: error
581 retention-days: 1
582​
583 # One job per platform and architecture (see release-desktop.yml), each
584 # gated only on the JS bundle. Windows targets build on Linux and run their
585 # native checks on a Windows runner of their own architecture.
586 # The Windows jobs also embed the same-arch Linux CLI archive as the WSL
587 # runtime; they wait for that artifact partway through instead of for the
588 # whole Linux job. Every job builds the desktop app; all but macOS x64 also
589 # build the CLI archive for their platform, so a target either ships fully or
590 # not at all.
591 desktop_mac_arm64:
592 name: Desktop macOS arm64
593 needs: [preflight, relay_public_config, build_bundle]
594 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
595 uses: ./.github/workflows/release-desktop.yml
596 secrets: inherit
597 with:
598 version: ${{ needs.preflight.outputs.version }}
599 ref: ${{ needs.preflight.outputs.ref }}
600 release_channel: ${{ needs.preflight.outputs.release_channel }}
601 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
602 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
603 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
604 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
605 label: macOS arm64
606 runner: blacksmith-12vcpu-macos-26
607 platform: mac
608 target: dmg
609 arch: arm64
610 rust_target: aarch64-apple-darwin
611 resource_key: darwin-arm64
612 cli_archive: true
613 launch_check: true
614​
615 desktop_mac_x64:
616 name: Desktop macOS x64
617 needs: [preflight, relay_public_config, build_bundle]
618 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
619 uses: ./.github/workflows/release-desktop.yml
620 secrets: inherit
621 with:
622 version: ${{ needs.preflight.outputs.version }}
623 ref: ${{ needs.preflight.outputs.ref }}
624 release_channel: ${{ needs.preflight.outputs.release_channel }}
625 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
626 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
627 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
628 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
629 label: macOS x64
630 runner: blacksmith-12vcpu-macos-26
631 platform: mac
632 target: dmg
633 arch: x64
634 rust_target: x86_64-apple-darwin
635 resource_key: darwin-x64
636 # No CLI archive: Node single-executables are unsupported on x64 macOS
637 # (the SEA docs list macOS as arm64 only) and the built binary segfaults
638 # on start. The x64 desktop app is Electron and unaffected.
639 cli_archive: false
640​
641 desktop_linux_x64:
642 name: Desktop Linux x64
643 needs: [preflight, relay_public_config, build_bundle]
644 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
645 uses: ./.github/workflows/release-desktop.yml
646 secrets: inherit
647 with:
648 version: ${{ needs.preflight.outputs.version }}
649 ref: ${{ needs.preflight.outputs.ref }}
650 release_channel: ${{ needs.preflight.outputs.release_channel }}
651 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
652 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
653 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
654 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
655 label: Linux x64
656 runner: blacksmith-32vcpu-ubuntu-2404
657 platform: linux
658 target: AppImage
659 arch: x64
660 rust_target: x86_64-unknown-linux-gnu
661 resource_key: linux-x64
662 cli_archive: true
663 launch_check: true
664​
665 # node-pty has no Linux prebuild and compiles from source, so the arm64 app
666 # and archive are built on arm64 hardware rather than cross-built.
667 desktop_linux_arm64:
668 name: Desktop Linux arm64
669 needs: [preflight, relay_public_config, build_bundle]
670 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
671 uses: ./.github/workflows/release-desktop.yml
672 secrets: inherit
673 with:
674 version: ${{ needs.preflight.outputs.version }}
675 ref: ${{ needs.preflight.outputs.ref }}
676 release_channel: ${{ needs.preflight.outputs.release_channel }}
677 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
678 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
679 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
680 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
681 label: Linux arm64
682 runner: blacksmith-16vcpu-ubuntu-2404-arm
683 platform: linux
684 target: AppImage
685 arch: arm64
686 rust_target: aarch64-unknown-linux-gnu
687 resource_key: linux-arm64
688 cli_archive: true
689​
690 # The Windows jobs start with the other platforms and wait for the same-arch
691 # Linux CLI archive after their other setup. Packaging is mostly CPU and
692 # small-file work, which Linux runners do faster than Windows ones, so both
693 # Windows targets build and sign on Linux and only the native checks run on
694 # Windows.
695 desktop_win_x64:
696 name: Desktop Windows x64
697 needs: [preflight, relay_public_config, build_bundle]
698 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
699 uses: ./.github/workflows/release-desktop.yml
700 secrets: inherit
701 with:
702 version: ${{ needs.preflight.outputs.version }}
703 ref: ${{ needs.preflight.outputs.ref }}
704 release_channel: ${{ needs.preflight.outputs.release_channel }}
705 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
706 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
707 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
708 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
709 label: Windows x64
710 runner: blacksmith-16vcpu-ubuntu-2404
711 verify_runner: windows-2025
712 platform: win
713 target: nsis
714 arch: x64
715 rust_target: x86_64-pc-windows-msvc
716 resource_key: win32-x64
717 cli_archive: true
718​
719 desktop_win_arm64:
720 name: Desktop Windows arm64
721 needs: [preflight, relay_public_config, build_bundle]
722 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.build_bundle.result == 'success' }}
723 uses: ./.github/workflows/release-desktop.yml
724 secrets: inherit
725 with:
726 version: ${{ needs.preflight.outputs.version }}
727 ref: ${{ needs.preflight.outputs.ref }}
728 release_channel: ${{ needs.preflight.outputs.release_channel }}
729 clerk_publishable_key: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
730 clerk_jwt_template: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
731 clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
732 relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
733 label: Windows arm64
734 runner: blacksmith-16vcpu-ubuntu-2404
735 verify_runner: windows-11-arm
736 platform: win
737 target: nsis
738 arch: arm64
739 rust_target: aarch64-pc-windows-msvc
740 resource_key: win32-arm64
741 cli_archive: true
742​
743 release:
744 name: Publish GitHub Release
745 needs:
746 [
747 preflight,
748 relay_public_config,
749 quality,
750 test,
751 test_web,
752 test_server,
753 desktop_mac_arm64,
754 desktop_mac_x64,
755 desktop_linux_x64,
756 desktop_linux_arm64,
757 desktop_win_x64,
758 desktop_win_arm64,
759 ]
760 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' }}
761 runs-on: blacksmith-8vcpu-ubuntu-2404
762 timeout-minutes: 30
763 permissions:
764 contents: write
765 # Release notes read PR bodies and authors.
766 pull-requests: read
767 steps:
768 - name: Checkout
769 uses: actions/checkout@v6
770 with:
771 ref: ${{ needs.preflight.outputs.ref }}
772 # Release notes need history back to the previous tag, not file contents.
773 fetch-depth: 0
774 filter: blob:none
775 sparse-checkout: |
776 /*
777 !/.repos/
778 sparse-checkout-cone-mode: false
779​
780 - name: Setup dependencies
781 uses: ./.github/actions/setup-ci-deps
782 with:
783 install-args: --filter=@t3tools/scripts...
784​
785 - name: Download all desktop artifacts
786 uses: actions/download-artifact@v8
787 with:
788 pattern: desktop-*
789 merge-multiple: true
790 path: release-assets
791​
792 - name: Download all CLI archives
793 uses: actions/download-artifact@v8
794 with:
795 pattern: cli-*
796 merge-multiple: true
797 path: release-assets
798​
799 - name: Download internal Android APK for Nightly
800 if: needs.preflight.outputs.release_channel == 'nightly'
801 continue-on-error: true
802 env:
803 GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
804 PACKAGE_NAME: com.t3tools.t3code
805 APK_OUTPUT_DIR: release-assets
806 run: |
807 if [ -n "$GOOGLE_PLAY_SERVICE_ACCOUNT_JSON" ]; then
808 node .github/scripts/mirror-play-apk.cjs
809 fi
810​
811 # Installers verify archives against this file, so it is written from the
812 # signed bytes that get uploaded, never from an earlier stage.
813 - name: Write CLI archive checksums
814 shell: bash
815 run: |
816 set -euo pipefail
817 cd release-assets
818 shopt -s nullglob
819 archives=(t3-*.tar.gz t3-*.zip)
820 if [[ ${#archives[@]} -eq 0 ]]; then
821 echo "No CLI archives were produced." >&2
822 exit 1
823 fi
824 sha256sum "${archives[@]}" > SHA256SUMS
825 cat SHA256SUMS
826​
827 # The desktop build omits the publish config for preview versions, so
828 # electron-builder emits no updater manifests for them. Refuse to publish
829 # if one shows up anyway: a `latest*.yml` or `nightly*.yml` on a preview
830 # release is what would let a stable or nightly install update onto it.
831 - name: Refuse updater metadata on preview releases
832 if: needs.preflight.outputs.release_channel == 'preview'
833 shell: bash
834 run: |
835 set -euo pipefail
836 shopt -s nullglob extglob
837 # builder-debug.yml is electron-builder's config dump, not a feed.
838 updater_files=(release-assets/!(builder-debug).yml release-assets/*.blockmap)
839 if [[ ${#updater_files[@]} -ne 0 ]]; then
840 printf 'Preview releases must not carry updater metadata, found: %s\n' "${updater_files[*]}" >&2
841 exit 1
842 fi
843​
844 # electron-updater reads one manifest per platform and channel and picks
845 # the file entry whose name carries the running arch, so the per-arch
846 # manifests the build jobs wrote are merged back into that one file.
847 - name: Merge macOS updater manifests
848 if: needs.preflight.outputs.release_channel != 'preview'
849 run: |
850 shopt -s nullglob
851 for x64_manifest in release-assets/*-mac-x64.yml; do
852 arm64_manifest="${x64_manifest%-x64.yml}.yml"
853 if [[ -f "$arm64_manifest" ]]; then
854 node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
855 rm -f "$x64_manifest"
856 fi
857 done
858​
859 - name: Merge Windows updater manifests
860 if: needs.preflight.outputs.release_channel != 'preview'
861 run: |
862 shopt -s nullglob
863 for x64_manifest in release-assets/*-win-x64.yml; do
864 arm64_manifest="${x64_manifest%-x64.yml}-arm64.yml"
865 merged_manifest="${x64_manifest%-win-x64.yml}.yml"
866 if [[ -f "$arm64_manifest" ]]; then
867 node scripts/merge-update-manifests.ts --platform win "$x64_manifest" "$arm64_manifest" "$merged_manifest"
868 rm -f "$x64_manifest" "$arm64_manifest"
869 else
870 mv "$x64_manifest" "$merged_manifest"
871 fi
872 done
873​
874 # Updater manifests and blockmaps are what electron-updater consumes.
875 # They are only listed for channels an updater is meant to follow.
876 - id: release_files
877 name: Resolve release asset list
878 shell: bash
879 run: |
880 {
881 echo 'files<<EOF'
882 echo 'release-assets/*.dmg'
883 echo 'release-assets/*.zip'
884 echo 'release-assets/*.AppImage'
885 echo 'release-assets/*.deb'
886 echo 'release-assets/*.exe'
887 if [[ "${{ needs.preflight.outputs.release_channel }}" != "preview" ]]; then
888 echo 'release-assets/*.blockmap'
889 echo 'release-assets/*.yml'
890 fi
891 echo 'release-assets/*.tar.gz'
892 # Only list APKs when Play has a processed internal build available.
893 for apk in release-assets/*.apk; do
894 [[ -f "$apk" ]] && echo "$apk"
895 done
896 echo 'release-assets/SHA256SUMS'
897 echo 'EOF'
898 } >> "$GITHUB_OUTPUT"
899​
900 # A short model summary over GitHub's full list. Without a notes file, the
901 # release falls back to GitHub's generated notes.
902 - name: Write release notes
903 if: needs.preflight.outputs.release_channel != 'preview' && needs.preflight.outputs.previous_tag != ''
904 continue-on-error: true
905 timeout-minutes: 5
906 env:
907 GH_TOKEN: ${{ github.token }}
908 OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
909 run: |
910 node scripts/generate-release-notes.ts \
911 --repository "${{ github.repository }}" \
912 --tag "${{ needs.preflight.outputs.tag }}" \
913 --ref "${{ needs.preflight.outputs.ref }}" \
914 --previous-tag "${{ needs.preflight.outputs.previous_tag }}" \
915 --version "${{ needs.preflight.outputs.version }}" \
916 --output release-notes.md
917 if [[ -f release-notes.md ]]; then
918 cat release-notes.md >> "$GITHUB_STEP_SUMMARY"
919 fi
920​
921 # A preview release gets a warning instead of generated notes. Generated
922 # notes would list every commit since the previous preview, which is
923 # unmerged branch history no one should read as a changelog, and would
924 # make the release look like any other build to someone browsing the
925 # releases page.
926 - name: Write preview release notes
927 if: needs.preflight.outputs.release_channel == 'preview'
928 shell: bash
929 run: |
930 cat > release-notes.md <<'EOF'
931 > [!WARNING]
932 > **This is a preview build. Do not install it unless you know exactly why you are here.**
933 >
934 > 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.
935​
936 Built from `${{ needs.preflight.outputs.ref }}`.
937 EOF
938​
939 - name: Publish release
940 if: needs.preflight.outputs.previous_tag != ''
941 uses: softprops/action-gh-release@v3
942 with:
943 tag_name: ${{ needs.preflight.outputs.tag }}
944 target_commitish: ${{ needs.preflight.outputs.ref }}
945 name: ${{ needs.preflight.outputs.release_name }}
946 generate_release_notes: ${{ hashFiles('release-notes.md') == '' }}
947 body_path: ${{ hashFiles('release-notes.md') != '' && 'release-notes.md' || '' }}
948 previous_tag: ${{ needs.preflight.outputs.previous_tag }}
949 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
950 draft: ${{ needs.preflight.outputs.is_prerelease }}
951 make_latest: ${{ needs.preflight.outputs.make_latest }}
952 files: ${{ steps.release_files.outputs.files }}
953 fail_on_unmatched_files: true
954 token: ${{ github.token }}
955​
956 - name: Publish first release
957 if: needs.preflight.outputs.previous_tag == ''
958 uses: softprops/action-gh-release@v3
959 with:
960 tag_name: ${{ needs.preflight.outputs.tag }}
961 target_commitish: ${{ needs.preflight.outputs.ref }}
962 name: ${{ needs.preflight.outputs.release_name }}
963 generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
964 body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
965 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
966 draft: ${{ needs.preflight.outputs.is_prerelease }}
967 make_latest: ${{ needs.preflight.outputs.make_latest }}
968 files: ${{ steps.release_files.outputs.files }}
969 fail_on_unmatched_files: true
970 token: ${{ github.token }}
971​
972 # The action keeps a stable release a draft until its assets finish uploading, but publishes a
973 # prerelease first. Desktop clients update connected servers from the CLI archives as soon as
974 # they see the release, so a prerelease also goes public only once every asset is attached.
975 - name: Publish prerelease
976 if: needs.preflight.outputs.is_prerelease == 'true'
977 env:
978 GH_TOKEN: ${{ github.token }}
979 GH_REPO: ${{ github.repository }}
980 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
981 run: gh release edit "$RELEASE_TAG" --draft=false
982​
983 # The `t3` npm package is a launcher that downloads this version's CLI
984 # archive from the GitHub Release, so it publishes only once that release
985 # exists. Preview publishes too, under the `preview` dist-tag, which
986 # nothing resolves unless asked for by name.
987 publish_cli:
988 name: Publish CLI to npm
989 needs: [preflight, release]
990 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
991 runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
992 timeout-minutes: 15
993 permissions:
994 contents: read
995 id-token: write
996 steps:
997 - name: Checkout
998 uses: actions/checkout@v6
999 with:
1000 ref: ${{ needs.preflight.outputs.ref }}
1001 sparse-checkout: |
1002 /*
1003 !/.repos/
1004 sparse-checkout-cone-mode: false
1005​
1006 - name: Setup dependencies
1007 uses: ./.github/actions/setup-ci-deps
1008 with:
1009 install-args: --filter=t3... --filter=@t3tools/scripts...
1010​
1011 - name: Build the npm launcher
1012 run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages
1013​
1014 - name: Publish the npm launcher
1015 run: |
1016 if ! node apps/server/scripts/cli.ts publish --packages-dir npm-packages --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --provenance --verbose; then
1017 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
1018 exit 1
1019 fi
1020​
1021 publish_aur:
1022 name: Publish AUR package
1023 needs: [preflight, release]
1024 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1025 uses: ./.github/workflows/publish-aur.yml
1026 with:
1027 release_tag: ${{ needs.preflight.outputs.tag }}
1028 secrets:
1029 AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
1030​
1031 # Vercel builds the hosted web app while the desktop jobs run. `--skip-domain`
1032 # keeps the custom domains (the channel and router domains) on the previous
1033 # deployment until deploy_web aliases them, after the GitHub Release. It does
1034 # still move the project's own *.vercel.app production hostname at build time.
1035 # That hostname sits behind Vercel SSO and is not a user channel, so the
1036 # npm-before-client order in docs/operations/release.md holds for users.
1037 build_web:
1038 name: Build hosted web app
1039 needs: [preflight, relay_public_config]
1040 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}
1041 runs-on: blacksmith-8vcpu-ubuntu-2404
1042 timeout-minutes: 10
1043 outputs:
1044 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1045 env:
1046 T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
1047 T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
1048 T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
1049 T3CODE_RELAY_URL: ${{ needs.relay_public_config.outputs.relay_url }}
1050 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1051 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1052 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1053 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1054 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1055 steps:
1056 - name: Checkout
1057 uses: actions/checkout@v6
1058 with:
1059 ref: ${{ needs.preflight.outputs.ref }}
1060 sparse-checkout: |
1061 /*
1062 !/.repos/
1063 sparse-checkout-cone-mode: false
1064​
1065 - name: Setup dependencies
1066 uses: ./.github/actions/setup-ci-deps
1067 with:
1068 install-args: --filter=@t3tools/scripts... --filter=@t3tools/web...
1069​
1070 - name: Download relay client tracing config
1071 uses: actions/download-artifact@v8
1072 with:
1073 name: relay-client-tracing-config
1074 path: ${{ runner.temp }}/relay-client-tracing
1075​
1076 - name: Load relay client tracing config
1077 shell: bash
1078 run: |
1079 config_path="$RUNNER_TEMP/relay-client-tracing/relay-client-tracing.env"
1080 tracing_token="$(sed -n 's/^T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=//p' "$config_path")"
1081 echo "::add-mask::$tracing_token"
1082 cat "$config_path" >> "$GITHUB_ENV"
1083​
1084 - name: Align package versions to release version
1085 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
1086​
1087 - name: Refresh release lockfile
1088 run: vp install --lockfile-only --ignore-scripts
1089​
1090 - id: deploy
1091 name: Build staged deployment
1092 shell: bash
1093 run: |
1094 set -euo pipefail
1095​
1096 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
1097 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
1098 exit 1
1099 fi
1100​
1101 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1102 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1103 channel_name="latest"
1104 else
1105 channel_name="nightly"
1106 fi
1107​
1108 echo "Building hosted web app for $channel_name channel."
1109 deployment_output="$(
1110 vp dlx vercel@53.1.1 deploy \
1111 --archive=tgz \
1112 --prod \
1113 --skip-domain \
1114 --yes \
1115 --token "$VERCEL_TOKEN" \
1116 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}" \
1117 --build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \
1118 --build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \
1119 --build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \
1120 --build-env "T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=${T3CODE_CLERK_CLI_OAUTH_CLIENT_ID:-}" \
1121 --build-env "T3CODE_RELAY_URL=${T3CODE_RELAY_URL:-}" \
1122 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=${T3CODE_RELAY_CLIENT_OTLP_TRACES_URL:-}" \
1123 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=${T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET:-}" \
1124 --build-env "T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=${T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN:-}" \
1125 --build-env "VITE_HOSTED_APP_URL=$router_url" \
1126 --build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
1127 )"
1128 printf '%s\n' "$deployment_output"
1129 # Vercel can print lockfile warnings to stdout before the deployment URL.
1130 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1131 if [[ "$deployment_url" == *$'\n'* ]]; then
1132 echo "Vercel returned multiple deployment URLs." >&2
1133 exit 1
1134 fi
1135 echo "Staged $deployment_url."
1136 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1137​
1138 deploy_web:
1139 name: Deploy hosted web app
1140 needs: [preflight, build_web, release, publish_cli]
1141 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' }}
1142 runs-on: blacksmith-2vcpu-ubuntu-2404
1143 timeout-minutes: 10
1144 env:
1145 DEPLOYMENT_URL: ${{ needs.build_web.outputs.deployment_url }}
1146 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1147 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1148 VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1149 T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}
1150 T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}
1151 T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}
1152 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1153 steps:
1154 - name: Checkout
1155 uses: actions/checkout@v6
1156 with:
1157 ref: ${{ needs.preflight.outputs.ref }}
1158 sparse-checkout: |
1159 /*
1160 !/.repos/
1161 sparse-checkout-cone-mode: false
1162​
1163 - name: Setup Vite+
1164 uses: ./.github/actions/setup-ci-deps
1165 with:
1166 install: false
1167​
1168 - name: Alias channel
1169 shell: bash
1170 run: |
1171 set -euo pipefail
1172​
1173 if [[ -z "$DEPLOYMENT_URL" ]]; then
1174 echo "Build hosted web app did not report a deployment URL." >&2
1175 exit 1
1176 fi
1177​
1178 router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"
1179 latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"
1180 nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"
1181 router_domain="${router_url#http://}"
1182 router_domain="${router_domain#https://}"
1183 router_domain="${router_domain%%/*}"
1184​
1185 if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then
1186 channel_domain="$latest_domain"
1187 channel_name="latest"
1188 else
1189 channel_domain="$nightly_domain"
1190 channel_name="nightly"
1191 fi
1192​
1193 vercel_scope_args=(--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}")
1194​
1195 echo "Aliasing $DEPLOYMENT_URL to $channel_domain."
1196 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$channel_domain" \
1197 --token "$VERCEL_TOKEN" \
1198 "${vercel_scope_args[@]}"
1199​
1200 if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then
1201 echo "Aliasing $DEPLOYMENT_URL to router domain $router_domain."
1202 vp dlx vercel@53.1.1 alias set "$DEPLOYMENT_URL" "$router_domain" \
1203 --token "$VERCEL_TOKEN" \
1204 "${vercel_scope_args[@]}"
1205 fi
1206​
1207 # Same split as the web app: build a production deployment early, then
1208 # promote it to t3.codes once the release it links to exists. As above, the
1209 # project's own *.vercel.app hostname moves at build time.
1210 build_marketing:
1211 name: Build marketing site
1212 needs: [preflight]
1213 if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1214 runs-on: blacksmith-8vcpu-ubuntu-2404
1215 timeout-minutes: 10
1216 outputs:
1217 deployment_url: ${{ steps.deploy.outputs.deployment_url }}
1218 project_id: ${{ steps.deploy.outputs.project_id }}
1219 env:
1220 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1221 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1222 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1223 steps:
1224 - name: Checkout
1225 uses: actions/checkout@v6
1226 with:
1227 ref: ${{ needs.preflight.outputs.ref }}
1228 sparse-checkout: |
1229 /*
1230 !/.repos/
1231 sparse-checkout-cone-mode: false
1232​
1233 - name: Setup dependencies
1234 uses: ./.github/actions/setup-ci-deps
1235 with:
1236 install-args: --filter=@t3tools/marketing...
1237​
1238 - id: deploy
1239 name: Build staged deployment
1240 shell: bash
1241 run: |
1242 set -euo pipefail
1243​
1244 if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" ]]; then
1245 echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID." >&2
1246 exit 1
1247 fi
1248​
1249 VERCEL_PROJECT_ID="$(
1250 curl --fail --silent --show-error \
1251 --header "Authorization: Bearer $VERCEL_TOKEN" \
1252 "https://api.vercel.com/v9/projects/t3code-marketing?teamId=$VERCEL_ORG_ID" \
1253 | jq --exit-status --raw-output '.id'
1254 )"
1255 export VERCEL_PROJECT_ID
1256​
1257 deployment_output="$(
1258 vp dlx vercel@53.1.1 deploy \
1259 --archive=tgz \
1260 --prod \
1261 --skip-domain \
1262 --yes \
1263 --token "$VERCEL_TOKEN" \
1264 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1265 )"
1266 printf '%s\n' "$deployment_output"
1267 # Vercel can print lockfile warnings to stdout before the deployment URL.
1268 deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1269 if [[ "$deployment_url" == *$'\n'* ]]; then
1270 echo "Vercel returned multiple deployment URLs." >&2
1271 exit 1
1272 fi
1273 echo "Staged $deployment_url."
1274 echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1275 echo "project_id=$VERCEL_PROJECT_ID" >> "$GITHUB_OUTPUT"
1276​
1277 deploy_marketing:
1278 name: Deploy marketing site
1279 needs: [preflight, build_marketing, release]
1280 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_marketing.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}
1281 runs-on: blacksmith-2vcpu-ubuntu-2404
1282 timeout-minutes: 10
1283 env:
1284 DEPLOYMENT_URL: ${{ needs.build_marketing.outputs.deployment_url }}
1285 VERCEL_PROJECT_ID: ${{ needs.build_marketing.outputs.project_id }}
1286 VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
1287 VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1288 VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
1289 steps:
1290 - name: Checkout
1291 uses: actions/checkout@v6
1292 with:
1293 ref: ${{ needs.preflight.outputs.ref }}
1294 sparse-checkout: |
1295 /*
1296 !/.repos/
1297 sparse-checkout-cone-mode: false
1298​
1299 - name: Setup Vite+
1300 uses: ./.github/actions/setup-ci-deps
1301 with:
1302 install: false
1303​
1304 - name: Promote marketing site
1305 shell: bash
1306 run: |
1307 set -euo pipefail
1308​
1309 if [[ -z "$DEPLOYMENT_URL" ]]; then
1310 echo "Build marketing site did not report a deployment URL." >&2
1311 exit 1
1312 fi
1313​
1314 echo "Promoting $DEPLOYMENT_URL."
1315 vp dlx vercel@53.1.1 promote "$DEPLOYMENT_URL" \
1316 --yes \
1317 --token "$VERCEL_TOKEN" \
1318 --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1319​
1320 finalize:
1321 name: Finalize release
1322 if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'stable' }}
1323 needs: [preflight, release]
1324 runs-on: blacksmith-8vcpu-ubuntu-2404
1325 timeout-minutes: 10
1326 steps:
1327 - id: app_token
1328 name: Mint release app token
1329 uses: actions/create-github-app-token@v2
1330 with:
1331 app-id: ${{ secrets.RELEASE_APP_ID }}
1332 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
1333 owner: ${{ github.repository_owner }}
1334​
1335 - name: Checkout
1336 uses: actions/checkout@v6
1337 with:
1338 ref: main
1339 fetch-depth: 0
1340 token: ${{ steps.app_token.outputs.token }}
1341 persist-credentials: true
1342 sparse-checkout: |
1343 /*
1344 !/.repos/
1345 sparse-checkout-cone-mode: false
1346​
1347 - id: app_bot
1348 name: Resolve GitHub App bot identity
1349 env:
1350 GH_TOKEN: ${{ steps.app_token.outputs.token }}
1351 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
1352 run: |
1353 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
1354 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
1355 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
1356​
1357 - name: Setup dependencies
1358 uses: ./.github/actions/setup-ci-deps
1359 with:
1360 install-args: --filter=@t3tools/scripts... --filter=@t3tools/oxlint-plugin-t3code...
1361​
1362 - id: update_versions
1363 name: Update version strings
1364 env:
1365 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
1366 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
1367​
1368 - name: Format package.json files
1369 if: steps.update_versions.outputs.changed == 'true'
1370 run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
1371​
1372 - name: Refresh lockfile
1373 if: steps.update_versions.outputs.changed == 'true'
1374 run: vp install --lockfile-only --ignore-scripts
1375​
1376 - name: Commit and push version bump
1377 if: steps.update_versions.outputs.changed == 'true'
1378 shell: bash
1379 env:
1380 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1381 run: |
1382 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml; then
1383 echo "No version changes to commit."
1384 exit 0
1385 fi
1386​
1387 git config user.name "${{ steps.app_bot.outputs.name }}"
1388 git config user.email "${{ steps.app_bot.outputs.email }}"
1389​
1390 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
1391 git commit --no-verify -m "chore(release): prepare $RELEASE_TAG"
1392 git push origin HEAD:main
1393​
1394 announce_discord:
1395 name: Announce release on Discord
1396 if: |
1397 always() && !cancelled() &&
1398 needs.preflight.result == 'success' &&
1399 needs.preflight.outputs.release_channel != 'preview' &&
1400 needs.relay_public_config.result == 'success' &&
1401 needs.release.result == 'success' &&
1402 needs.deploy_web.result == 'success' &&
1403 (needs.finalize.result == 'success' || needs.finalize.result == 'skipped')
1404 needs: [preflight, relay_public_config, release, deploy_web, finalize]
1405 runs-on: blacksmith-8vcpu-ubuntu-2404
1406 timeout-minutes: 10
1407 steps:
1408 - name: Checkout
1409 uses: actions/checkout@v6
1410 with:
1411 ref: ${{ needs.preflight.outputs.ref }}
1412 sparse-checkout: |
1413 /*
1414 !/.repos/
1415 sparse-checkout-cone-mode: false
1416​
1417 - name: Setup dependencies
1418 uses: ./.github/actions/setup-ci-deps
1419 with:
1420 install-args: --filter=@t3tools/scripts...
1421​
1422 - name: Read published release notes
1423 if: needs.preflight.outputs.is_prerelease == 'true'
1424 continue-on-error: true
1425 env:
1426 GH_TOKEN: ${{ github.token }}
1427 GH_REPO: ${{ github.repository }}
1428 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
1429 RELEASE_CHANNEL: ${{ needs.preflight.outputs.release_channel }}
1430 run: |
1431 if [ "$RELEASE_CHANNEL" = 'nightly' ]; then
1432 if ! gh release view "$RELEASE_TAG" --json body --jq '.body // ""' > "$RUNNER_TEMP/discord-release-notes.md"; then
1433 : > "$RUNNER_TEMP/discord-release-notes.md"
1434 echo '::warning::Could not read published release notes; announcing without a changelog.'
1435 fi
1436 else
1437 : > "$RUNNER_TEMP/discord-release-notes.md"
1438 fi
1439​
1440 - name: Announce prerelease on Discord
1441 if: needs.preflight.outputs.is_prerelease == 'true'
1442 continue-on-error: true
1443 env:
1444 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_NIGHTLY_ROLE_ID }}
1445 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1446 run: |
1447 node scripts/notify-discord-release.ts prerelease \
1448 --role-id "$DISCORD_MENTION_ROLE_ID" \
1449 --release-name "${{ needs.preflight.outputs.release_name }}" \
1450 --release-version "${{ needs.preflight.outputs.version }}" \
1451 --tag "${{ needs.preflight.outputs.tag }}" \
1452 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}" \
1453 --release-notes-file "$RUNNER_TEMP/discord-release-notes.md"
1454​
1455 - name: Announce latest release on Discord
1456 if: needs.preflight.outputs.make_latest == 'true'
1457 continue-on-error: true
1458 env:
1459 DISCORD_MENTION_ROLE_ID: ${{ secrets.DISCORD_RELEASE_LATEST_ROLE_ID }}
1460 DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
1461 run: |
1462 node scripts/notify-discord-release.ts latest \
1463 --role-id "$DISCORD_MENTION_ROLE_ID" \
1464 --release-name "${{ needs.preflight.outputs.release_name }}" \
1465 --release-version "${{ needs.preflight.outputs.version }}" \
1466 --tag "${{ needs.preflight.outputs.tag }}" \
1467 --release-url "https://github.com/${{ github.repository }}/releases/tag/${{ needs.preflight.outputs.tag }}"