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