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