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