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