TypeScript
perf(release): build Vercel deployments early and go live after publish (#14029)
Theo Browne783ccf0fdde0
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex acd5720018c..443665e020f 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -948,12 +948,20 @@ jobs:secrets:AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}- deploy_web:- name: Deploy hosted web app- needs: [preflight, relay_public_config, release]- if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}+ # Vercel builds the hosted web app while the desktop jobs run. `--skip-domain`+ # keeps the custom domains (the channel and router domains) on the previous+ # deployment until deploy_web aliases them, after the GitHub Release. It does+ # still move the project's own *.vercel.app production hostname at build time.+ # That hostname sits behind Vercel SSO and is not a user channel, so the+ # npm-before-client order in docs/operations/release.md holds for users.+ build_web:+ name: Build hosted web app+ needs: [preflight, relay_public_config]+ if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}runs-on: blacksmith-8vcpu-ubuntu-2404timeout-minutes: 10+ outputs:+ deployment_url: ${{ steps.deploy.outputs.deployment_url }}env:T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}@@ -963,8 +971,6 @@ jobs:VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}- T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}- T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}steps:- name: Checkout@@ -1006,7 +1012,8 @@ jobs:- name: Refresh release lockfilerun: vp install --lockfile-only --ignore-scripts- - name: Deploy and alias channel+ - id: deploy+ name: Build staged deploymentshell: bashrun: |set -euo pipefail@@ -1017,24 +1024,13 @@ jobs:firouter_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"- latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"- nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"- router_domain="${router_url#http://}"- router_domain="${router_domain#https://}"- router_domain="${router_domain%%/*}"-if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then- channel_domain="$latest_domain"channel_name="latest"else- channel_domain="$nightly_domain"channel_name="nightly"fi- vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"- vercel_scope_args=(--scope "$vercel_scope")-- echo "Deploying hosted web app for $channel_name channel."+ echo "Building hosted web app for $channel_name channel."deployment_url="$(vp dlx [email protected] deploy \--archive=tgz \@@ -1042,7 +1038,7 @@ jobs:--skip-domain \--yes \--token "$VERCEL_TOKEN" \- "${vercel_scope_args[@]}" \+ --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}" \--build-env "APP_VERSION=${{ needs.preflight.outputs.version }}" \--build-env "T3CODE_CLERK_PUBLISHABLE_KEY=${T3CODE_CLERK_PUBLISHABLE_KEY:-}" \--build-env "T3CODE_CLERK_JWT_TEMPLATE=${T3CODE_CLERK_JWT_TEMPLATE:-}" \@@ -1054,25 +1050,92 @@ jobs:--build-env "VITE_HOSTED_APP_URL=$router_url" \--build-env "VITE_HOSTED_APP_CHANNEL=$channel_name")"+ echo "Staged $deployment_url."+ echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"- echo "Aliasing $deployment_url to $channel_domain."- vp dlx [email protected] alias set "$deployment_url" "$channel_domain" \+ deploy_web:+ name: Deploy hosted web app+ needs: [preflight, build_web, release]+ if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_web.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel != 'preview' }}+ runs-on: blacksmith-2vcpu-ubuntu-2404+ timeout-minutes: 10+ env:+ DEPLOYMENT_URL: ${{ needs.build_web.outputs.deployment_url }}+ VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}+ VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}+ VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}+ T3CODE_WEB_ROUTER_URL: ${{ vars.T3CODE_WEB_ROUTER_URL }}+ T3CODE_WEB_LATEST_DOMAIN: ${{ vars.T3CODE_WEB_LATEST_DOMAIN }}+ T3CODE_WEB_NIGHTLY_DOMAIN: ${{ vars.T3CODE_WEB_NIGHTLY_DOMAIN }}+ VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}+ steps:+ - name: Checkout+ uses: actions/checkout@v6+ with:+ ref: ${{ needs.preflight.outputs.ref }}+ sparse-checkout: |+ /*+ !/.repos/+ sparse-checkout-cone-mode: false++ - name: Setup Vite++ uses: voidzero-dev/setup-vp@v1+ with:+ node-version-file: package.json+ cache: false+ run-install: false++ - name: Alias channel+ shell: bash+ run: |+ set -euo pipefail++ if [[ -z "$DEPLOYMENT_URL" ]]; then+ echo "Build hosted web app did not report a deployment URL." >&2+ exit 1+ fi++ router_url="${T3CODE_WEB_ROUTER_URL:-https://app.t3.codes}"+ latest_domain="${T3CODE_WEB_LATEST_DOMAIN:-latest.app.t3.codes}"+ nightly_domain="${T3CODE_WEB_NIGHTLY_DOMAIN:-nightly.app.t3.codes}"+ router_domain="${router_url#http://}"+ router_domain="${router_domain#https://}"+ router_domain="${router_domain%%/*}"++ if [[ "${{ needs.preflight.outputs.release_channel }}" == "stable" ]]; then+ channel_domain="$latest_domain"+ channel_name="latest"+ else+ channel_domain="$nightly_domain"+ channel_name="nightly"+ fi++ vercel_scope_args=(--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}")++ echo "Aliasing $DEPLOYMENT_URL to $channel_domain."+ vp dlx [email protected] alias set "$DEPLOYMENT_URL" "$channel_domain" \--token "$VERCEL_TOKEN" \"${vercel_scope_args[@]}"if [[ "$channel_name" == "latest" && -n "$router_domain" && "$router_domain" != "$channel_domain" ]]; then- echo "Aliasing $deployment_url to router domain $router_domain."- vp dlx [email protected] alias set "$deployment_url" "$router_domain" \+ echo "Aliasing $DEPLOYMENT_URL to router domain $router_domain."+ vp dlx [email protected] alias set "$DEPLOYMENT_URL" "$router_domain" \--token "$VERCEL_TOKEN" \"${vercel_scope_args[@]}"fi- deploy_marketing:- name: Deploy marketing site- needs: [preflight, release]- if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}+ # Same split as the web app: build a production deployment early, then+ # promote it to t3.codes once the release it links to exists. As above, the+ # project's own *.vercel.app hostname moves at build time.+ build_marketing:+ name: Build marketing site+ needs: [preflight]+ if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}runs-on: blacksmith-8vcpu-ubuntu-2404timeout-minutes: 10+ outputs:+ deployment_url: ${{ steps.deploy.outputs.deployment_url }}+ project_id: ${{ steps.deploy.outputs.project_id }}env:VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}@@ -1096,7 +1159,8 @@ jobs:args:- --filter=@t3tools/marketing...- - name: Deploy marketing site to Vercel+ - id: deploy+ name: Build staged deploymentshell: bashrun: |set -euo pipefail@@ -1114,9 +1178,60 @@ jobs:)"export VERCEL_PROJECT_ID- vp dlx [email protected] deploy \- --archive=tgz \- --prod \+ deployment_url="$(+ vp dlx [email protected] deploy \+ --archive=tgz \+ --prod \+ --skip-domain \+ --yes \+ --token "$VERCEL_TOKEN" \+ --scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"+ )"+ echo "Staged $deployment_url."+ echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"+ echo "project_id=$VERCEL_PROJECT_ID" >> "$GITHUB_OUTPUT"++ deploy_marketing:+ name: Deploy marketing site+ needs: [preflight, build_marketing, release]+ if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build_marketing.result == 'success' && needs.release.result == 'success' && needs.preflight.outputs.release_channel == 'nightly' }}+ runs-on: blacksmith-2vcpu-ubuntu-2404+ timeout-minutes: 10+ env:+ DEPLOYMENT_URL: ${{ needs.build_marketing.outputs.deployment_url }}+ VERCEL_PROJECT_ID: ${{ needs.build_marketing.outputs.project_id }}+ VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}+ VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}+ VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}+ steps:+ - name: Checkout+ uses: actions/checkout@v6+ with:+ ref: ${{ needs.preflight.outputs.ref }}+ sparse-checkout: |+ /*+ !/.repos/+ sparse-checkout-cone-mode: false++ - name: Setup Vite++ uses: voidzero-dev/setup-vp@v1+ with:+ node-version-file: package.json+ cache: false+ run-install: false++ - name: Promote marketing site+ shell: bash+ run: |+ set -euo pipefail++ if [[ -z "$DEPLOYMENT_URL" ]]; then+ echo "Build marketing site did not report a deployment URL." >&2+ exit 1+ fi++ echo "Promoting $DEPLOYMENT_URL."+ vp dlx [email protected] promote "$DEPLOYMENT_URL" \--yes \--token "$VERCEL_TOKEN" \--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"diff --git a/docs/operations/release.md b/docs/operations/release.mdindex d4e4c666029..d0da6154512 100644--- a/docs/operations/release.md+++ b/docs/operations/release.md@@ -47,7 +47,7 @@ This document covers the unified release workflow for stable and nightly desktop- nightly releases publish npm dist-tag `nightly`- preview releases publish npm dist-tag `preview`, which nothing resolves unless asked for by name- one-time setup: the `@t3code` npm scope (org) must exist, and `t3` and each `@t3code/t3-<platform>-<arch>` package needs a trusted publisher registered for this workflow file (see below).-- Deploys the hosted web app to Vercel only after a release is published:+- Builds the hosted web app on Vercel while the desktop jobs run, and makes it live only after a release is published:- stable releases are aliased to the `latest` hosted app channel- nightly releases are aliased to the `nightly` hosted app channel- Signing is optional and auto-detected per platform from secrets.@@ -211,9 +211,11 @@ stage, test Cloudflare account, disposable host, and disposable T3 home. Keep pr## Marketing site deployment-After a nightly release is published, the release workflow deploys the same commit-to the marketing site's Vercel production project. Stable releases do not deploy-the marketing site because they can promote an older nightly commit.+On nightly releases, the release workflow builds the same commit as a staged+production deployment of the marketing site's Vercel project while the desktop+jobs run, and promotes it with `vercel promote` after the release is published.+Stable releases do not deploy the marketing site because they can promote an+older nightly commit.The job looks up the `t3code-marketing` project using the existing `VERCEL_TOKEN`and `VERCEL_ORG_ID` secrets. It also respects the optional `VERCEL_TEAM_SLUG`@@ -224,8 +226,10 @@ Git deployments remain disabled in `apps/marketing/vercel.ts`.The hosted app is intentionally not deployed by Vercel's Git integration. Theweb project disables automatic Git deployments in `apps/web/vercel.ts` via-`git.deploymentEnabled: false`, and `.github/workflows/release.yml` deploys the-web app with Vercel CLI after the GitHub Release succeeds.+`git.deploymentEnabled: false`. `.github/workflows/release.yml` builds the web+app with Vercel CLI as a staged production deployment (`--skip-domain`) while+the desktop jobs run, and aliases the channel domains to it after the GitHub+Release succeeds.Required GitHub Actions secrets:@@ -302,6 +306,10 @@ The workflow enforces this ordering:1. `publish_cli` publishes the exact release version to npm, on every channel.2. `release` depends on `publish_cli` before exposing desktop artifacts in GitHub Releases.3. `deploy_web` depends on `release` before moving the hosted channel to the new client.+ `build_web` builds that client earlier with `vercel deploy --prod --skip-domain`, which+ leaves the custom domains alone but moves the project's own `*.vercel.app` production+ hostname. That hostname is behind Vercel SSO, so users only get the client through the+ custom domains.Preserve these dependencies when changing the release graph. Publishing a client first would leavethe **Update server** action targeting a package version that does not exist yet.