Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
# Optional: T3 Connect source builds
# `cp .env.example .env` enables T3 Connect against the production deployment.
# These are the same public identifiers baked into official release builds, not
# secrets. Remove or comment them out to build with cloud features disabled.
# Do not add server-side secrets to this file.
# Optional: Fork Connect source builds
# Copy to `.env` and fill in your fork-owned deployment values to enable Connect.
# These are public build identifiers, not secrets. Leave commented out or unset
# for a cloudless build (direct and Tailscale pairing remain available).
# Upstream domains and Clerk keys are rejected. Do not add server-side secrets here.

# Production Clerk instance. To use your own, get these from the Clerk Dashboard
# under API keys, JWT templates, and OAuth applications.
T3CODE_CLERK_PUBLISHABLE_KEY=pk_live_Y2xlcmsudDMuY29kZXMk
T3CODE_CLERK_JWT_TEMPLATE=t3-relay
T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=hzxSgY2cH10sDU2r
# Fork Clerk instance (Clerk Dashboard -> API keys, JWT templates, OAuth applications).
# T3CODE_CLERK_PUBLISHABLE_KEY=pk_live_...
# T3CODE_CLERK_JWT_TEMPLATE=t3-relay
# T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=...

# Optional: signed macOS passkey builds. The RP domain defaults to the Frontend API
# hostname encoded in T3CODE_CLERK_PUBLISHABLE_KEY. Set the override only when Clerk
# returns a different RP ID or when multiple domains must be entitled.
# T3CODE_APPLE_TEAM_ID=ABC1234567
# T3CODE_MACOS_PROVISIONING_PROFILE=/absolute/path/to/t3code.provisionprofile
# T3CODE_CLERK_PASSKEY_RP_DOMAINS=example.clerk.accounts.dev,clerk.example.com
# Fork relay URL and pinned Ed25519 credential-minting public key (single-line
# \n-escaped PEM). Local `infra/relay` deploys update both automatically, and
# `deploy-relay.yml` prints them in its workflow summary.
# T3CODE_RELAY_URL=https://relay.<your-domain>
# T3CODE_CLOUD_MINT_PUBLIC_KEY=-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----

# Production relay. For a self-hosted relay, `infra/relay` deploys update it
# automatically.
T3CODE_RELAY_URL=https://relay.t3.codes
# Optional: hosted web app origin for browser-based CLI OAuth (`/connect`).
# Omit when no hosted web app is deployed; the CLI automatically uses Clerk's
# device-authorization flow instead.
# T3CODE_HOSTED_APP_URL=https://app.<your-domain>

# Optional: hosted app origin used by the CLI's out-of-band OAuth flow.
# Defaults to https://app.t3.codes; override to test against a staging deployment.
# T3CODE_HOSTED_APP_URL=https://nightly.app.t3.codes
# Optional: signed macOS passkey builds. Signed macOS builds only enable
# Associated Domains passkeys when T3CODE_MACOS_PROVISIONING_PROFILE or
# T3CODE_CLERK_PASSKEY_RP_DOMAINS is set.
# T3CODE_APPLE_TEAM_ID=ABC1234567
# T3CODE_MACOS_PROVISIONING_PROFILE=/absolute/path/to/s2code.provisionprofile
# T3CODE_CLERK_PASSKEY_RP_DOMAINS=example.clerk.accounts.dev,clerk.<your-domain>

# Public, ingest-only mobile OpenTelemetry configuration.
# Optional: public, ingest-only mobile OpenTelemetry configuration.
# T3CODE_MOBILE_OTLP_TRACES_URL=https://api.axiom.co/v1/traces
# T3CODE_MOBILE_OTLP_TRACES_DATASET=t3-code-mobile-traces-dev
# T3CODE_MOBILE_OTLP_TRACES_TOKEN=xaat-...
186 changes: 181 additions & 5 deletions .github/workflows/deploy-relay.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,192 @@
name: Relay deployment (disabled)
name: Deploy Connect relay

on:
push:
branches:
- main
paths:
- "infra/relay/**"
- "packages/contracts/**"
- "packages/shared/**"
- "packages/client-runtime/**"
- "pnpm-lock.yaml"
- ".github/workflows/deploy-relay.yml"
# Redeploys main after a variable or secret change. Alchemy redeploys the
# Worker when a value it reads changes, so force is rarely needed.
workflow_dispatch:
inputs:
force:
description: Redeploy every resource, including ones with no detected changes.
type: boolean
default: false

permissions:
contents: read
id-token: none
statuses: write

concurrency:
group: relay-production
cancel-in-progress: false

jobs:
unavailable:
deploy_relay:
name: Deploy production relay
# Manual runs from another branch would deploy that branch to production.
# Push runs skip cleanly while RELAY_API_ZONE_NAME is unset at repository scope.
if: >-
github.repository == 'shuv1337/s2code' &&
github.ref == 'refs/heads/main' &&
(github.event_name == 'workflow_dispatch' || vars.RELAY_API_ZONE_NAME != '')
runs-on: ubuntu-24.04
timeout-minutes: 15
environment:
name: production
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
PLANETSCALE_ORGANIZATION: ${{ vars.PLANETSCALE_ORGANIZATION }}
AXIOM_ORG_ID: ${{ vars.AXIOM_ORG_ID }}
RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
RELAY_TUNNEL_ZONE_NAME: ${{ vars.RELAY_TUNNEL_ZONE_NAME }}
RELAY_DB_HOST: ${{ vars.RELAY_DB_HOST }}
RELAY_DB_PORT: ${{ vars.RELAY_DB_PORT }}
RELAY_DB_NAME: ${{ vars.RELAY_DB_NAME }}
RELAY_DB_USER: ${{ vars.RELAY_DB_USER }}
RELAY_DB_CONNECTION_LIMIT: ${{ vars.RELAY_DB_CONNECTION_LIMIT }}
RELAY_DB_MIGRATION_SSLMODE: ${{ vars.RELAY_DB_MIGRATION_SSLMODE }}
RELAY_DB_CLUSTER_SIZE: ${{ vars.RELAY_DB_CLUSTER_SIZE }}
RELAY_DB_REPLICAS: ${{ vars.RELAY_DB_REPLICAS }}
RELAY_OTLP_TRACES_URL: ${{ vars.RELAY_OTLP_TRACES_URL }}
RELAY_TUNNEL_CLEANUP_MODE: ${{ vars.RELAY_TUNNEL_CLEANUP_MODE }}
RELAY_LEGACY_TUNNEL_CLEANUP_MODE: ${{ vars.RELAY_LEGACY_TUNNEL_CLEANUP_MODE }}
CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
CLERK_JWT_AUDIENCE: ${{ vars.CLERK_JWT_AUDIENCE }}
APNS_ENABLED: ${{ vars.APNS_ENABLED || 'false' }}
ALCHEMY_TELEMETRY_DISABLED: "1"
steps:
- name: Hosted relay deployment unavailable
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false

- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
with:
node-version-file: package.json
cache: true
run-install: |
args:
- --filter=t3code-relay...

- name: Verify fork relay ownership configuration
env:
RELAY_DB_PASSWORD: ${{ secrets.RELAY_DB_PASSWORD }}
RELAY_DB_ACCESS_CLIENT_ID: ${{ secrets.RELAY_DB_ACCESS_CLIENT_ID }}
RELAY_DB_ACCESS_CLIENT_SECRET: ${{ secrets.RELAY_DB_ACCESS_CLIENT_SECRET }}
AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
run: node --input-type=module -e 'import { assertForkRelayDeploymentEnv } from "./infra/relay/src/forkOwnership.ts"; assertForkRelayDeploymentEnv(process.env);'

- name: Run external Postgres migrations
if: env.RELAY_DB_HOST != ''
env:
RELAY_DB_PASSWORD: ${{ secrets.RELAY_DB_PASSWORD }}
TUNNEL_SERVICE_TOKEN_ID: ${{ secrets.RELAY_DB_ACCESS_CLIENT_ID }}
TUNNEL_SERVICE_TOKEN_SECRET: ${{ secrets.RELAY_DB_ACCESS_CLIENT_SECRET }}
run: |
set -euo pipefail
if [ -n "$TUNNEL_SERVICE_TOKEN_ID" ] || [ -n "$TUNNEL_SERVICE_TOKEN_SECRET" ]; then
if [ -z "$TUNNEL_SERVICE_TOKEN_ID" ] || [ -z "$TUNNEL_SERVICE_TOKEN_SECRET" ]; then
echo "::error::RELAY_DB_ACCESS_CLIENT_ID and RELAY_DB_ACCESS_CLIENT_SECRET must both be set." >&2
exit 1
fi
cf_bin="$RUNNER_TEMP/cloudflared"
curl -fsSL --retry 3 -o "$cf_bin" \
"https://github.com/cloudflare/cloudflared/releases/download/2026.10.4/cloudflared-linux-amd64"
echo "ae5e8add7884b0531d66bbca4570d1de491ff6da51e4ebe7eb160cdf241d9e42 $cf_bin" | sha256sum -c -
chmod +x "$cf_bin"
# Service token credentials travel through TUNNEL_SERVICE_TOKEN_* env, never argv.
"$cf_bin" access tcp \
--hostname "$RELAY_DB_HOST" \
--url 127.0.0.1:15432 &
cf_pid=$!
trap 'kill "$cf_pid" 2>/dev/null || true' EXIT
node -e '
const net = require("node:net");
const deadline = Date.now() + 15_000;
(function probe() {
const socket = net.connect(15432, "127.0.0.1");
socket.once("connect", () => { socket.destroy(); process.exit(0); });
socket.once("error", () => {
socket.destroy();
if (Date.now() >= deadline) {
console.error("Timed out waiting for cloudflared access tcp listener.");
process.exit(1);
}
setTimeout(probe, 200);
});
})();
'
RELAY_DB_MIGRATION_TARGET_HOST="127.0.0.1" \
RELAY_DB_MIGRATION_TARGET_PORT="15432" \
RELAY_DB_MIGRATION_SSLMODE="${RELAY_DB_MIGRATION_SSLMODE:-disable}" \
vp run --filter t3code-relay migrate:postgres
else
RELAY_DB_MIGRATION_SSLMODE="${RELAY_DB_MIGRATION_SSLMODE:-require}" \
vp run --filter t3code-relay migrate:postgres
fi

- name: Deploy production relay stage
run: vp run --filter t3code-relay deploy --stage prod --yes --no-input ${{ inputs.force && '--force' || '' }}
env:
# The PublishClientConfig action writes the client env here instead
# of the repo-root .env; nothing on the runner reads it.
T3CODE_RELAY_CLIENT_CONFIG_ENV: ${{ runner.temp }}/relay-client-config.env
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
PLANETSCALE_API_TOKEN_ID: ${{ secrets.PLANETSCALE_API_TOKEN_ID }}
PLANETSCALE_API_TOKEN: ${{ secrets.PLANETSCALE_API_TOKEN }}
AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
RELAY_DB_PASSWORD: ${{ secrets.RELAY_DB_PASSWORD }}
RELAY_DB_ACCESS_CLIENT_ID: ${{ secrets.RELAY_DB_ACCESS_CLIENT_ID }}
RELAY_DB_ACCESS_CLIENT_SECRET: ${{ secrets.RELAY_DB_ACCESS_CLIENT_SECRET }}
RELAY_OTLP_TRACES_TOKEN: ${{ secrets.RELAY_OTLP_TRACES_TOKEN }}

- name: Publish relay deploy commit status
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: "success",
context: "Relay deploy / production",
description: "Relay production deploy completed.",
target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
});

- name: Publish public relay outputs to summary
env:
CLIENT_CONFIG_ENV: ${{ runner.temp }}/relay-client-config.env
run: |
echo '::notice::Hosted relay deployment is not supported in this fork. No resources were provisioned. Direct and Tailscale pairing remain available.'
echo 'Hosted relay deployment is disabled for this fork. See docs/operations/hosted-fork.md.' >> "$GITHUB_STEP_SUMMARY"
set -euo pipefail
node --input-type=module -e '
import * as fs from "node:fs";
import * as util from "node:util";
const file = process.env.CLIENT_CONFIG_ENV;
const summary = process.env.GITHUB_STEP_SUMMARY;
if (!file || !summary) process.exit(0);
if (!fs.existsSync(file)) {
fs.appendFileSync(summary, "### Public relay outputs\n\nUnchanged since previous deploy.\n");
process.exit(0);
}
const parsed = util.parseEnv(fs.readFileSync(file, "utf8"));
const lines = ["### Public relay outputs", ""];
if (parsed.T3CODE_RELAY_URL) lines.push(`- \`T3CODE_RELAY_URL\`: \`${parsed.T3CODE_RELAY_URL}\``);
if (parsed.T3CODE_CLOUD_MINT_PUBLIC_KEY) lines.push(`- \`T3CODE_CLOUD_MINT_PUBLIC_KEY\`: \`${parsed.T3CODE_CLOUD_MINT_PUBLIC_KEY}\``);
fs.appendFileSync(summary, `${lines.join("\n")}\n`);
'
7 changes: 7 additions & 0 deletions .github/workflows/encrypted-windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
AGE_RECIPIENT: ${{ inputs.recipient }}
S2CODE_DESKTOP_UPDATE_REPOSITORY: shuv1337/s2code
CSC_IDENTITY_AUTO_DISCOVERY: "false"
T3CODE_RELAY_URL: ${{ vars.T3CODE_RELAY_URL }}
T3CODE_CLOUD_MINT_PUBLIC_KEY: ${{ vars.T3CODE_CLOUD_MINT_PUBLIC_KEY }}
T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }}
T3CODE_CLERK_JWT_TEMPLATE: ${{ vars.T3CODE_CLERK_JWT_TEMPLATE }}
T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID }}
T3CODE_HOSTED_APP_URL: ${{ vars.T3CODE_HOSTED_APP_URL }}
steps:
# Public fetch needs no credential injection or recursive submodule cleanup.
# The vendored .repos tree contains incomplete nested submodule metadata.
Expand Down Expand Up @@ -94,6 +100,7 @@ jobs:
shell: bash
run: |
set -euo pipefail
node --input-type=module -e 'import { resolveForkConnectReleaseConfig } from "./scripts/lib/fork-release.ts"; resolveForkConnectReleaseConfig(process.env);'
node scripts/update-release-package-versions.ts "$PRIVATE_BUILD_VERSION"
cargo build --locked --release --manifest-path native/resource-monitor/Cargo.toml
mkdir -p release-private/linux-resource-monitor
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/relay-preview-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
cleanup_pr:
name: Tear down relay preview
if: >-
github.repository == 'shuv1337/s2code' &&
vars.RELAY_PREVIEWS_ENABLED == 'true' &&
github.ref == 'refs/heads/main' &&
github.event_name == 'pull_request_target' &&
(
Expand Down Expand Up @@ -100,7 +102,11 @@ jobs:

list_closed_previews:
name: List closed relay previews
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request_target'
if: >-
github.repository == 'shuv1337/s2code' &&
vars.RELAY_PREVIEWS_ENABLED == 'true' &&
github.ref == 'refs/heads/main' &&
github.event_name != 'pull_request_target'
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
Expand All @@ -124,7 +130,11 @@ jobs:
sweep_pr:
name: Retry teardown for PR ${{ matrix.number }}
needs: list_closed_previews
if: github.ref == 'refs/heads/main' && needs.list_closed_previews.outputs.numbers != '[]'
if: >-
github.repository == 'shuv1337/s2code' &&
vars.RELAY_PREVIEWS_ENABLED == 'true' &&
github.ref == 'refs/heads/main' &&
needs.list_closed_previews.outputs.numbers != '[]'
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/relay-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
deploy_preview:
name: Deploy relay preview
if: >-
github.repository == 'shuv1337/s2code' &&
vars.RELAY_PREVIEWS_ENABLED == 'true' &&
github.event.pull_request.head.repo.full_name == github.repository &&
contains(github.event.pull_request.labels.*.name, 'relay:preview')
runs-on: ubuntu-24.04
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/release-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ on:
relay_url:
required: false
type: string
cloud_mint_public_key:
required: false
type: string
hosted_app_url:
required: false
type: string
release_publication:
required: false
default: false
Expand Down Expand Up @@ -170,6 +176,8 @@ jobs:
T3CODE_CLERK_JWT_TEMPLATE: ${{ inputs.clerk_jwt_template }}
T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ inputs.clerk_cli_oauth_client_id }}
T3CODE_RELAY_URL: ${{ inputs.relay_url }}
T3CODE_CLOUD_MINT_PUBLIC_KEY: ${{ inputs.cloud_mint_public_key }}
T3CODE_HOSTED_APP_URL: ${{ inputs.hosted_app_url }}
AZURE_SIGNING_AUTH: ${{ inputs.platform == 'win' && inputs.win_signed && vars.AZURE_SIGNING_AUTH || '' }}
AZURE_SUBSCRIPTION_ID: ${{ inputs.platform == 'win' && inputs.win_signed && vars.AZURE_SUBSCRIPTION_ID || '' }}
S2CODE_DESKTOP_UPDATE_REPOSITORY: shuv1337/s2code
Expand Down
Loading
Loading