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