feat(server): install preview runtimes from release archives #11318
Mergedjuliusmarmingemerged 9 commits into
sea/release-archives fromrefs/pull/11318/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/cloud/pinnedRuntime.ts lines 197 to 206OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -91,0 +186,21 @@186+ stderrLength: result.stderr.length,187+ }),188+ ),189+ );190+});191+192+const fetchReleaseAsset = Effect.fn("cloud.pinned_runtime.fetch_release_asset")(function* (193+ httpClient: HttpClient.HttpClient,194+ url: string,195+ step: string,196+) {197+ const response = yield* httpClient.execute(HttpClientRequest.get(url)).pipe(198+ Effect.flatMap(HttpClientResponse.filterStatusOk),199+ Effect.mapError((cause) => new PinnedRuntimeInstallError({ step, cause })),200+ );201+ return new Uint8Array(202+ yield* response.arrayBuffer.pipe(203+ Effect.mapError((cause) => new PinnedRuntimeInstallError({ step, cause })),204+ ),205+ );206+});apps/server/src/cloud/selfUpdate.ts lines 184 to 188Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -171,3 +178,8 @@171178 const fs = yield* FileSystem.FileSystem;172179 const path = yield* Path.Path;173180 const execPath = yield* HostProcessExecutablePath;181+ const platform = yield* HostProcessPlatform;182+ const arch = yield* HostProcessArchitecture;183+ // Archive-distributed targets download from GitHub Releases. The client is184+ // optional so callers without one (tests, npm-only hosts) still construct.185+ const httpClient = Option.getOrUndefined(yield* Effect.serviceOption(HttpClient.HttpClient));packages/shared/src/cliRelease.ts lines 8 to 11OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,11 @@1+/**2+ * Naming shared by the release workflow, the runtime installers, and3+ * install scripts for the per-platform CLI archives attached to GitHub4+ * Releases. Every consumer derives the same file names from a version and a5+ * platform key, so a rename here is a release-breaking change.6+ */7+8+export const CLI_RELEASE_REPOSITORY = "pingdotgg/t3code";9+export const CLI_RELEASE_CHECKSUMS_FILE = "SHA256SUMS";10+/** Overrides the download origin for mirrors and air-gapped installs. */11+export const CLI_RELEASE_BASE_URL_ENV = "T3CODE_RELEASE_BASE_URL";@@ -0,0 +61,21 @@61+archive="${stem}.tar.gz"62+versions_dir="${t3_home}/runtime/versions"63+target_dir="${versions_dir}/${version}"64+65+if [ -f "${target_dir}/.install-complete" ] && [ "$(cat "${target_dir}/.install-complete")" = "$version" ]; then66+ printf 't3 %s is already installed at %s\n' "$version" "$target_dir"67+else68+ mkdir -p "$versions_dir"69+ staging="$(mktemp -d "${versions_dir}/.staging-XXXXXX")"70+ trap 'rm -rf "$staging"' EXIT71+72+ printf 'Downloading %s...\n' "$archive"73+ fetch "${base_url}/v${version}/SHA256SUMS" "${staging}/SHA256SUMS"74+ fetch "${base_url}/v${version}/${archive}" "${staging}/${archive}"75+76+ expected="$(grep " \*\{0,1\}${archive}\$" "${staging}/SHA256SUMS" | cut -d' ' -f1)"77+ [ -n "$expected" ] || fail "${archive} is not listed in SHA256SUMS"78+ if command -v sha256sum >/dev/null 2>&1; then79+ actual="$(sha256sum "${staging}/${archive}" | cut -d' ' -f1)"80+ else81+ actual="$(shasum -a 256 "${staging}/${archive}" | cut -d' ' -f1)"
- apps/server/src/cloud/pinnedRuntime.ts line 229Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -91,0 +205,21 @@205+ );206+});207+208+/**209+ * Downloads the release archive for this platform, verifies it against the210+ * release's checksum file, and unpacks it so the executable sits directly in211+ * the staging directory. Only `tar` is required on the host; every supported212+ * OS ships one that reads gzip and zip.213+ */214+const installFromArchive = Effect.fn("cloud.pinned_runtime.install_archive")(function* (215+ input: PinnedRuntimeInstallInput,216+ stagingDir: string,217+) {218+ const { fs, path } = input;219+ const platformKey = cliArchivePlatformKey(input.platform, input.arch);220+ if (platformKey === undefined) {221+ return yield* new PinnedRuntimeInstallError({222+ step: `selecting a t3 release archive for ${input.platform}-${input.arch}`,223+ });224+ }225+ const httpClient = input.httpClient;
- apps/marketing/public/install.sh line 77Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +57,21 @@57+version="${T3CODE_VERSION:-}"58+if [ -z "$version" ]; then59+ # Preview is the only train shipping archives while they are being dogfooded.60+ tmp_index="$(mktemp)"61+ fetch "https://api.github.com/repos/${repo}/releases?per_page=50" "$tmp_index"62+ version="$(sed -n 's/.*"tag_name": *"v\([0-9][^"]*-preview\.[0-9]*\.[0-9]*\)".*/\1/p' "$tmp_index" | head -n 1)"63+ rm -f "$tmp_index"64+ [ -n "$version" ] || fail "could not find a preview release; set T3CODE_VERSION"65+fi66+67+stem="t3-${version}-${platform}-${arch}"68+archive="${stem}.tar.gz"69+versions_dir="${t3_home}/runtime/versions"70+target_dir="${versions_dir}/${version}"71+72+if [ -f "${target_dir}/.install-complete" ] && [ "$(cat "${target_dir}/.install-complete")" = "$version" ]; then73+ printf 't3 %s is already installed at %s\n' "$version" "$target_dir"74+else75+ mkdir -p "$versions_dir"76+ staging="$(mktemp -d "${versions_dir}/.staging-XXXXXX")"77+ trap 'rm -rf "$staging"' EXIT
- apps/server/src/serviceLauncher.ts line 429Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -402,4 +416,5 @@402416 childVersion: version,403417 ...(update === undefined ? {} : { update }),404418 };405- const child = NodeChildProcess.spawn(process.execPath, [paths.entryPath, "serve"], {419+ const spawnArguments = runtimeSpawnArguments(paths);420+ const child = NodeChildProcess.spawn(spawnArguments.command, spawnArguments.args, {apps/marketing/public/install.ps1 lines 84 to 84OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +64,21 @@64+65+ Expand-Archive -Path (Join-Path $staging $archive) -DestinationPath $staging -Force66+ # The archive wraps everything in one directory named after its stem.67+ Get-ChildItem (Join-Path $staging $stem) | Move-Item -Destination $staging68+ Remove-Item (Join-Path $staging $stem), (Join-Path $staging $archive), (Join-Path $staging "SHA256SUMS") -Recurse -Force69+70+ & (Join-Path $staging "t3.exe") --version | Out-Null71+ if ($LASTEXITCODE -ne 0) { Fail "the downloaded executable does not run" }72+ Set-Content -Path (Join-Path $staging ".install-complete") -Value $version -NoNewline73+74+ if (Test-Path $targetDir) { Remove-Item $targetDir -Recurse -Force }75+ Move-Item $staging $targetDir76+ } catch {77+ if (Test-Path $staging) { Remove-Item $staging -Recurse -Force }78+ throw79+ }80+}81+82+New-Item -ItemType Directory -Force -Path $binDir | Out-Null83+$shim = Join-Path $binDir "t3.cmd"84+Set-Content -Path $shim -Value "@echo off`r`n`"$(Join-Path $targetDir 't3.exe')`" %*" -Encoding ASCII
- apps/marketing/public/install.ps1 line 27OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +7,21 @@7+# T3CODE_VERSION exact version to install (default: latest preview release)8+# T3CODE_HOME T3 home directory (default: ~\.t3)9+# T3CODE_INSTALL_BIN_DIR where t3.exe is linked (default: ~\.local\bin)10+# T3CODE_RELEASE_BASE_URL mirror for releases/download (default: GitHub)11+#12+# The archive is unpacked into $T3CODE_HOME\runtime\versions\<version>, the13+# same layout `t3 service install` uses, so the service reuses this download.14+$ErrorActionPreference = "Stop"15+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls1216+17+$repo = "pingdotgg/t3code"18+$baseUrl = if ($env:T3CODE_RELEASE_BASE_URL) { $env:T3CODE_RELEASE_BASE_URL.TrimEnd("/") } else { "https://github.com/$repo/releases/download" }19+$t3Home = if ($env:T3CODE_HOME) { $env:T3CODE_HOME } else { Join-Path $HOME ".t3" }20+$binDir = if ($env:T3CODE_INSTALL_BIN_DIR) { $env:T3CODE_INSTALL_BIN_DIR } else { Join-Path $HOME ".local\bin" }21+22+function Fail([string] $message) {23+ Write-Error "t3 install: $message"24+ exit 125+}26+27+$arch = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
- packages/shared/src/cliRelease.ts line 13OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,13 @@1+/**2+ * Naming shared by the release workflow, the runtime installers, and3+ * install scripts for the per-platform CLI archives attached to GitHub4+ * Releases. Every consumer derives the same file names from a version and a5+ * platform key, so a rename here is a release-breaking change.6+ */7+8+const CLI_RELEASE_REPOSITORY = "pingdotgg/t3code";9+export const CLI_RELEASE_CHECKSUMS_FILE = "SHA256SUMS";10+/** Overrides the download origin for mirrors and air-gapped installs. */11+export const CLI_RELEASE_BASE_URL_ENV = "T3CODE_RELEASE_BASE_URL";12+13+export type CliArchivePlatformKey =@@ -91,0 +261,21 @@261+ });262+ if (Encoding.encodeHex(new Uint8Array(digest)) !== expected) {263+ return yield* new PinnedRuntimeInstallError({264+ step: "verifying the t3 release archive checksum",265+ });266+ }267+268+ const archivePath = path.join(stagingDir, PINNED_RUNTIME_ARCHIVE_FILE);269+ yield* fs270+ .writeFile(archivePath, archive)271+ .pipe(272+ Effect.mapError(273+ (cause) => new PinnedRuntimeInstallError({ step: "writing the t3 release archive", cause }),274+ ),275+ );276+ const extractStep = "extracting the t3 release archive";277+ // The archive wraps everything in one directory named after its stem;278+ // strip it so the executable lands at <versionDir>/t3.279+ yield* input.runner280+ .run({281+ command: "tar",
juliusmarminge merged this8f90b38
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
4b582ac· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.