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