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