Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off
2import { execFileSync } from "node:child_process";
3import {
4 cpSync,
5 existsSync,
6 mkdirSync,
7 mkdtempSync,
8 readFileSync,
9 rmSync,
10 writeFileSync,
11} from "node:fs";
12import { tmpdir } from "node:os";
13import { dirname, join, resolve } from "node:path";
14import { fileURLToPath } from "node:url";
15import * as Console from "effect/Console";
16import * as Effect from "effect/Effect";
17
18const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
19
20const workspaceFiles = [
21 "package.json",
22 "pnpm-lock.yaml",
23 "pnpm-workspace.yaml",
24 "apps/server/package.json",
25 "apps/desktop/package.json",
26 "apps/web/package.json",
27 "apps/mobile/package.json",
28 "apps/mobile/deps/react-native-nitro-markdown-0.5.0.tgz",
29 "apps/mobile/modules/t3-review-diff/package.json",
30 "apps/mobile/modules/t3-terminal/package.json",
31 "apps/marketing/package.json",
32 "infra/relay/package.json",
33 "oxlint-plugin-t3code/package.json",
34 "packages/client-runtime/package.json",
35 "packages/contracts/package.json",
36 "packages/shared/package.json",
37 "packages/ssh/package.json",
38 "packages/tailscale/package.json",
39 "packages/effect-acp/package.json",
40 "packages/effect-codex-app-server/package.json",
41 "scripts/package.json",
42] as const;
43
44function copyWorkspaceManifestFixture(targetRoot: string): void {
45 for (const relativePath of workspaceFiles) {
46 const sourcePath = resolve(repoRoot, relativePath);
47 const destinationPath = resolve(targetRoot, relativePath);
48 mkdirSync(dirname(destinationPath), { recursive: true });
49 cpSync(sourcePath, destinationPath);
50 }
51
52 const patchesDirectory = resolve(repoRoot, "patches");
53 if (existsSync(patchesDirectory)) {
54 cpSync(patchesDirectory, resolve(targetRoot, "patches"), { recursive: true });
55 }
56}
57
58function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
59 const assetDirectory = resolve(targetRoot, "release-assets");
60 mkdirSync(assetDirectory, { recursive: true });
61
62 const arm64Path = resolve(assetDirectory, "latest-mac.yml");
63 const x64Path = resolve(assetDirectory, "latest-mac-x64.yml");
64
65 writeFileSync(
66 arm64Path,
67 `version: 9.9.9-smoke.0
68files:
69 - url: T3-Code-9.9.9-smoke.0-arm64.zip
70 sha512: arm64zip
71 size: 125621344
72 - url: T3-Code-9.9.9-smoke.0-arm64.dmg
73 sha512: arm64dmg
74 size: 131754935
75path: T3-Code-9.9.9-smoke.0-arm64.zip
76sha512: arm64zip
77releaseDate: '2026-03-08T10:32:14.587Z'
78`,
79 );
80
81 writeFileSync(
82 x64Path,
83 `version: 9.9.9-smoke.0
84files:
85 - url: T3-Code-9.9.9-smoke.0-x64.zip
86 sha512: x64zip
87 size: 132000112
88 - url: T3-Code-9.9.9-smoke.0-x64.dmg
89 sha512: x64dmg
90 size: 138148807
91path: T3-Code-9.9.9-smoke.0-x64.zip
92sha512: x64zip
93releaseDate: '2026-03-08T10:36:07.540Z'
94`,
95 );
96
97 return { arm64Path, x64Path };
98}
99
100function writeWindowsManifestFixtures(
101 targetRoot: string,
102 channel: string,
103): { arm64Path: string; x64Path: string } {
104 const assetDirectory = resolve(targetRoot, "release-assets");
105 mkdirSync(assetDirectory, { recursive: true });
106
107 const arm64Path = resolve(assetDirectory, `${channel}-win-arm64.yml`);
108 const x64Path = resolve(assetDirectory, `${channel}-win-x64.yml`);
109
110 writeFileSync(
111 arm64Path,
112 `version: 9.9.9-smoke.0
113files:
114 - url: T3-Code-9.9.9-smoke.0-arm64.exe
115 sha512: arm64exe
116 size: 126621344
117 - url: T3-Code-9.9.9-smoke.0-arm64.exe.blockmap
118 sha512: arm64blockmap
119 size: 152344
120path: T3-Code-9.9.9-smoke.0-arm64.exe
121sha512: arm64exe
122releaseDate: '2026-03-08T10:32:14.587Z'
123`,
124 );
125
126 writeFileSync(
127 x64Path,
128 `version: 9.9.9-smoke.0
129files:
130 - url: T3-Code-9.9.9-smoke.0-x64.exe
131 sha512: x64exe
132 size: 132000112
133 - url: T3-Code-9.9.9-smoke.0-x64.exe.blockmap
134 sha512: x64blockmap
135 size: 160112
136path: T3-Code-9.9.9-smoke.0-x64.exe
137sha512: x64exe
138releaseDate: '2026-03-08T10:36:07.540Z'
139`,
140 );
141
142 return { arm64Path, x64Path };
143}
144
145function writeWindowsBuilderDebugFixtures(targetRoot: string): {
146 arm64Path: string;
147 x64Path: string;
148} {
149 const assetDirectory = resolve(targetRoot, "release-assets");
150 mkdirSync(assetDirectory, { recursive: true });
151
152 const arm64Path = resolve(assetDirectory, "builder-debug-win-arm64.yml");
153 const x64Path = resolve(assetDirectory, "builder-debug-win-x64.yml");
154 const debugFixture = `arm64:
155 firstOrDefaultFilePatterns:
156 - '**/*'
157nsis:
158 script: |-
159 !include "example.nsh"
160`;
161
162 writeFileSync(arm64Path, debugFixture);
163 writeFileSync(x64Path, debugFixture);
164
165 return { arm64Path, x64Path };
166}
167function assertContains(haystack: string, needle: string, message: string): void {
168 if (!haystack.includes(needle)) {
169 throw new Error(message);
170 }
171}
172
173function assertExists(path: string, message: string): void {
174 if (!existsSync(path)) {
175 throw new Error(message);
176 }
177}
178
179function assertPackageVersion(path: string, version: string): void {
180 const packageJson = JSON.parse(readFileSync(path, "utf8")) as {
181 readonly version?: unknown;
182 };
183
184 if (packageJson.version !== version) {
185 throw new Error(`Expected ${path} to have version ${version}.`);
186 }
187}
188
189function assertMissing(path: string, message: string): void {
190 if (existsSync(path)) {
191 throw new Error(message);
192 }
193}
194
195const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-"));
196
197try {
198 copyWorkspaceManifestFixture(tempRoot);
199
200 execFileSync(
201 process.execPath,
202 [
203 resolve(repoRoot, "scripts/update-release-package-versions.ts"),
204 "9.9.9-smoke.0",
205 "--root",
206 tempRoot,
207 ],
208 {
209 cwd: repoRoot,
210 stdio: "inherit",
211 },
212 );
213
214 rmSync(resolve(tempRoot, "pnpm-lock.yaml"), { force: true });
215
216 execFileSync("vp", ["install", "--lockfile-only", "--ignore-scripts"], {
217 cwd: tempRoot,
218 stdio: "inherit",
219 });
220
221 const lockfile = readFileSync(resolve(tempRoot, "pnpm-lock.yaml"), "utf8");
222 assertContains(lockfile, "lockfileVersion:", "Expected pnpm-lock.yaml to be regenerated.");
223
224 for (const relativePath of [
225 "apps/server/package.json",
226 "apps/desktop/package.json",
227 "apps/web/package.json",
228 "packages/contracts/package.json",
229 ]) {
230 assertPackageVersion(resolve(tempRoot, relativePath), "9.9.9-smoke.0");
231 }
232
233 const nightlyReleaseMetadata = execFileSync(
234 process.execPath,
235 [
236 resolve(repoRoot, "scripts/resolve-nightly-release.ts"),
237 "--date",
238 "20260413",
239 "--run-number",
240 "321",
241 "--sha",
242 "abcdef1234567890",
243 "--root",
244 tempRoot,
245 ],
246 {
247 cwd: repoRoot,
248 encoding: "utf8",
249 },
250 );
251 assertContains(
252 nightlyReleaseMetadata,
253 "version=9.9.10-nightly.20260413.321",
254 "Expected nightly metadata to contain the derived nightly version.",
255 );
256 assertContains(
257 nightlyReleaseMetadata,
258 "tag=v9.9.10-nightly.20260413.321",
259 "Expected nightly metadata to contain the derived nightly tag.",
260 );
261 assertContains(
262 nightlyReleaseMetadata,
263 "name=T3 Code Nightly 9.9.10-nightly.20260413.321 (abcdef123456)",
264 "Expected nightly metadata to include the short commit SHA in the release name.",
265 );
266
267 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
268 execFileSync(
269 process.execPath,
270 [
271 resolve(repoRoot, "scripts/merge-update-manifests.ts"),
272 "--platform",
273 "mac",
274 arm64Path,
275 x64Path,
276 ],
277 {
278 cwd: repoRoot,
279 stdio: "inherit",
280 },
281 );
282
283 const mergedManifest = readFileSync(arm64Path, "utf8");
284 assertContains(
285 mergedManifest,
286 "T3-Code-9.9.9-smoke.0-arm64.zip",
287 "Merged manifest is missing the arm64 asset.",
288 );
289 assertContains(
290 mergedManifest,
291 "T3-Code-9.9.9-smoke.0-x64.zip",
292 "Merged manifest is missing the x64 asset.",
293 );
294
295 const { arm64Path: winArm64Path, x64Path: winX64Path } = writeWindowsManifestFixtures(
296 tempRoot,
297 "latest",
298 );
299 const mergedWindowsManifestPath = resolve(tempRoot, "release-assets/latest.yml");
300 const { arm64Path: nightlyWinArm64Path, x64Path: nightlyWinX64Path } =
301 writeWindowsManifestFixtures(tempRoot, "nightly");
302 const mergedNightlyWindowsManifestPath = resolve(tempRoot, "release-assets/nightly.yml");
303 const { arm64Path: previewWinArm64Path, x64Path: previewWinX64Path } =
304 writeWindowsManifestFixtures(tempRoot, "preview");
305 const mergedPreviewWindowsManifestPath = resolve(tempRoot, "release-assets/preview.yml");
306 const { arm64Path: winDebugArm64Path, x64Path: winDebugX64Path } =
307 writeWindowsBuilderDebugFixtures(tempRoot);
308 execFileSync(
309 "bash",
310 [
311 "-lc",
312 `
313 release_assets_dir=${JSON.stringify(resolve(tempRoot, "release-assets"))}
314 shopt -s nullglob
315 found_windows_manifest=false
316 for x64_manifest in "$release_assets_dir"/*-win-x64.yml; do
317 if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
318 continue
319 fi
320
321 arm64_manifest="\${x64_manifest/-x64.yml/-arm64.yml}"
322 output_manifest="\${x64_manifest/-win-x64.yml/.yml}"
323 if [[ ! -f "$arm64_manifest" ]]; then
324 echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
325 exit 1
326 fi
327
328 found_windows_manifest=true
329 ${JSON.stringify(process.execPath)} ${JSON.stringify(resolve(repoRoot, "scripts/merge-update-manifests.ts"))} --platform win \
330 "$arm64_manifest" \
331 "$x64_manifest" \
332 "$output_manifest"
333 rm -f "$arm64_manifest" "$x64_manifest"
334 done
335
336 if [[ "$found_windows_manifest" != true ]]; then
337 echo "No Windows updater manifests found to merge." >&2
338 exit 1
339 fi
340 `,
341 ],
342 {
343 cwd: repoRoot,
344 stdio: "inherit",
345 },
346 );
347
348 const mergedWindowsManifest = readFileSync(mergedWindowsManifestPath, "utf8");
349 assertContains(
350 mergedWindowsManifest,
351 "T3-Code-9.9.9-smoke.0-arm64.exe",
352 "Merged Windows manifest is missing the arm64 asset.",
353 );
354 assertContains(
355 mergedWindowsManifest,
356 "T3-Code-9.9.9-smoke.0-x64.exe",
357 "Merged Windows manifest is missing the x64 asset.",
358 );
359 const mergedNightlyWindowsManifest = readFileSync(mergedNightlyWindowsManifestPath, "utf8");
360 assertContains(
361 mergedNightlyWindowsManifest,
362 "T3-Code-9.9.9-smoke.0-arm64.exe",
363 "Merged nightly Windows manifest is missing the arm64 asset.",
364 );
365 assertContains(
366 mergedNightlyWindowsManifest,
367 "T3-Code-9.9.9-smoke.0-x64.exe",
368 "Merged nightly Windows manifest is missing the x64 asset.",
369 );
370 const mergedPreviewWindowsManifest = readFileSync(mergedPreviewWindowsManifestPath, "utf8");
371 assertContains(
372 mergedPreviewWindowsManifest,
373 "T3-Code-9.9.9-smoke.0-arm64.exe",
374 "Merged preview Windows manifest is missing the arm64 asset.",
375 );
376 assertContains(
377 mergedPreviewWindowsManifest,
378 "T3-Code-9.9.9-smoke.0-x64.exe",
379 "Merged preview Windows manifest is missing the x64 asset.",
380 );
381 assertMissing(
382 winArm64Path,
383 "Windows release smoke unexpectedly kept the arm64 updater manifest.",
384 );
385 assertMissing(winX64Path, "Windows release smoke unexpectedly kept the x64 updater manifest.");
386 assertMissing(
387 nightlyWinArm64Path,
388 "Windows release smoke unexpectedly kept the nightly arm64 updater manifest.",
389 );
390 assertMissing(
391 nightlyWinX64Path,
392 "Windows release smoke unexpectedly kept the nightly x64 updater manifest.",
393 );
394 assertMissing(
395 previewWinArm64Path,
396 "Windows release smoke unexpectedly kept the preview arm64 updater manifest.",
397 );
398 assertMissing(
399 previewWinX64Path,
400 "Windows release smoke unexpectedly kept the preview x64 updater manifest.",
401 );
402 assertExists(
403 winDebugArm64Path,
404 "Windows release smoke unexpectedly removed the arm64 builder debug fixture.",
405 );
406 assertExists(
407 winDebugX64Path,
408 "Windows release smoke unexpectedly removed the x64 builder debug fixture.",
409 );
410
411 Effect.runSync(Console.log("Release smoke checks passed."));
412} finally {
413 rmSync(tempRoot, { recursive: true, force: true });
414}