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