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