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