@devries-cameron20 / t3code Mirror · read-only / commits / a8e60d4602
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 16:00 UTC

fix(release): require complete updater manifests (#23700)

Co-authored-by: Tejas Parmar <parmartejas@vanojay.in> Co-authored-by: Julius Marminge <julius0216@outlook.com>

parmartejas committed Nov 14, 2026 at 13:27 UTC a8e60d4602cf51e127548d1176b3e2cbb562c2bf
4 files changed +241 -85
.github/workflows/release.yml
+5 -27
@@ -903,34 +903,12 @@ jobs:
903 fi
904
905 # electron-updater reads one manifest per platform and channel and picks
906 - # the file entry whose name carries the running arch, so the per-arch
907 - # manifests the build jobs wrote are merged back into that one file.
908 - - name: Merge macOS updater manifests
906 + # the file entry whose name carries the running arch. Require every
907 + # platform's two build jobs to have produced matching metadata before
908 + # merging it, so a successful release can never strand one architecture.
909 + - name: Merge desktop updater manifests
910 if: needs.preflight.outputs.release_channel != 'preview'
910 - run: |
911 - shopt -s nullglob
912 - for x64_manifest in release-assets/*-mac-x64.yml; do
913 - arm64_manifest="${x64_manifest%-x64.yml}.yml"
914 - if [[ -f "$arm64_manifest" ]]; then
915 - node scripts/merge-update-manifests.ts --platform mac "$arm64_manifest" "$x64_manifest"
916 - rm -f "$x64_manifest"
917 - fi
918 - done
919 -
920 - - name: Merge Windows updater manifests
921 - if: needs.preflight.outputs.release_channel != 'preview'
922 - run: |
923 - shopt -s nullglob
924 - for x64_manifest in release-assets/*-win-x64.yml; do
925 - arm64_manifest="${x64_manifest%-x64.yml}-arm64.yml"
926 - merged_manifest="${x64_manifest%-win-x64.yml}.yml"
927 - if [[ -f "$arm64_manifest" ]]; then
928 - node scripts/merge-update-manifests.ts --platform win "$x64_manifest" "$arm64_manifest" "$merged_manifest"
929 - rm -f "$x64_manifest" "$arm64_manifest"
930 - else
931 - mv "$x64_manifest" "$merged_manifest"
932 - fi
933 - done
911 + run: node scripts/merge-release-update-manifests.ts release-assets
912
913 # Updater manifests and blockmaps are what electron-updater consumes.
914 # They are only listed for channels an updater is meant to follow.
scripts/merge-release-update-manifests.test.ts new
+83
@@ -0,0 +1,83 @@
1 +import * as NodeServices from "@effect/platform-node/NodeServices";
2 +import { assert, it } from "@effect/vitest";
3 +import * as Effect from "effect/Effect";
4 +import * as FileSystem from "effect/FileSystem";
5 +import * as Path from "effect/Path";
6 +
7 +import { mergeReleaseUpdateManifestFiles } from "./merge-release-update-manifests.ts";
8 +
9 +const manifest = (fileName: string) => `version: 1.2.3
10 +files:
11 + - url: ${fileName}
12 + sha512: ${fileName}-sha
13 + size: 123
14 +releaseDate: '2026-10-22T00:00:00.000Z'
15 +`;
16 +
17 +it.layer(NodeServices.layer)("merge release update manifests", (it) => {
18 + it.effect("merges complete macOS and Windows architecture pairs", () =>
19 + Effect.gen(function* () {
20 + const fs = yield* FileSystem.FileSystem;
21 + const path = yield* Path.Path;
22 + const releaseAssetsDir = yield* fs.makeTempDirectoryScoped({
23 + prefix: "merge-release-update-manifests-",
24 + });
25 + const fixtures = {
26 + "latest-mac.yml": manifest("T3-Code-1.2.3-arm64.zip"),
27 + "latest-mac-x64.yml": manifest("T3-Code-1.2.3-x64.zip"),
28 + "latest-win-arm64.yml": manifest("T3-Code-1.2.3-arm64.exe"),
29 + "latest-win-x64.yml": manifest("T3-Code-1.2.3-x64.exe"),
30 + };
31 + yield* Effect.forEach(Object.entries(fixtures), ([fileName, contents]) =>
32 + fs.writeFileString(path.join(releaseAssetsDir, fileName), contents),
33 + );
34 +
35 + yield* mergeReleaseUpdateManifestFiles(releaseAssetsDir);
36 +
37 + const mac = yield* fs.readFileString(path.join(releaseAssetsDir, "latest-mac.yml"));
38 + const win = yield* fs.readFileString(path.join(releaseAssetsDir, "latest.yml"));
39 + assert.include(mac, "T3-Code-1.2.3-arm64.zip");
40 + assert.include(mac, "T3-Code-1.2.3-x64.zip");
41 + assert.include(win, "T3-Code-1.2.3-arm64.exe");
42 + assert.include(win, "T3-Code-1.2.3-x64.exe");
43 + assert.isFalse(yield* fs.exists(path.join(releaseAssetsDir, "latest-mac-x64.yml")));
44 + assert.isFalse(yield* fs.exists(path.join(releaseAssetsDir, "latest-win-arm64.yml")));
45 + assert.isFalse(yield* fs.exists(path.join(releaseAssetsDir, "latest-win-x64.yml")));
46 + }),
47 + );
48 +
49 + it.effect.each([
50 + {
51 + platform: "macOS",
52 + fixtures: ["latest-mac.yml", "latest-win-arm64.yml", "latest-win-x64.yml"],
53 + },
54 + {
55 + platform: "macOS",
56 + fixtures: ["latest-mac-x64.yml", "latest-win-arm64.yml", "latest-win-x64.yml"],
57 + },
58 + {
59 + platform: "Windows",
60 + fixtures: ["latest-mac.yml", "latest-mac-x64.yml", "latest-win-arm64.yml"],
61 + },
62 + {
63 + platform: "Windows",
64 + fixtures: ["latest-mac.yml", "latest-mac-x64.yml", "latest-win-x64.yml"],
65 + },
66 + ] as const)("refuses a one-architecture $platform release", ({ platform, fixtures }) =>
67 + Effect.gen(function* () {
68 + const fs = yield* FileSystem.FileSystem;
69 + const path = yield* Path.Path;
70 + const releaseAssetsDir = yield* fs.makeTempDirectoryScoped({
71 + prefix: "merge-release-update-manifests-incomplete-",
72 + });
73 + yield* Effect.forEach(fixtures, (fileName) =>
74 + fs.writeFileString(path.join(releaseAssetsDir, fileName), manifest(fileName)),
75 + );
76 +
77 + const exit = yield* mergeReleaseUpdateManifestFiles(releaseAssetsDir).pipe(Effect.exit);
78 +
79 + assert.equal(exit._tag, "Failure");
80 + assert.include(String(exit), `Incomplete ${platform} updater manifests`);
81 + }),
82 + );
83 +});
scripts/merge-release-update-manifests.ts new
+137
@@ -0,0 +1,137 @@
1 +#!/usr/bin/env node
2 +
3 +import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
4 +import * as NodeServices from "@effect/platform-node/NodeServices";
5 +import * as Effect from "effect/Effect";
6 +import * as FileSystem from "effect/FileSystem";
7 +import * as Path from "effect/Path";
8 +import { Argument, Command } from "effect/cli";
9 +
10 +import { mergeUpdateManifestFiles, type UpdateManifestPlatform } from "./merge-update-manifests.ts";
11 +
12 +interface ReleaseUpdateManifestMerge {
13 + readonly platform: UpdateManifestPlatform;
14 + readonly primary: string;
15 + readonly secondary: string;
16 + readonly output: string;
17 +}
18 +
19 +function pairArchitectures(
20 + platformLabel: string,
21 + arm64: ReadonlyMap<string, string>,
22 + x64: ReadonlyMap<string, string>,
23 +): ReadonlyArray<{ readonly channel: string; readonly arm64: string; readonly x64: string }> {
24 + const channels = new Set([...arm64.keys(), ...x64.keys()]);
25 + if (channels.size === 0) {
26 + throw new Error(
27 + `Incomplete ${platformLabel} updater manifests: no architecture manifests found.`,
28 + );
29 + }
30 + return [...channels].toSorted().map((channel) => {
31 + const arm64Manifest = arm64.get(channel);
32 + const x64Manifest = x64.get(channel);
33 + if (arm64Manifest === undefined || x64Manifest === undefined) {
34 + const missing = arm64Manifest === undefined ? "arm64" : "x64";
35 + throw new Error(
36 + `Incomplete ${platformLabel} updater manifests: ${channel} is missing its ${missing} manifest.`,
37 + );
38 + }
39 + return { channel, arm64: arm64Manifest, x64: x64Manifest };
40 + });
41 +}
42 +
43 +function planReleaseUpdateManifestMerges(
44 + fileNames: ReadonlyArray<string>,
45 +): ReadonlyArray<ReleaseUpdateManifestMerge> {
46 + const macArm64 = new Map<string, string>();
47 + const macX64 = new Map<string, string>();
48 + const winArm64 = new Map<string, string>();
49 + const winX64 = new Map<string, string>();
50 +
51 + for (const fileName of fileNames) {
52 + if (fileName.startsWith("builder-debug")) continue;
53 +
54 + const macArm64Match = /^(.+)-mac\.yml$/u.exec(fileName);
55 + if (macArm64Match?.[1] !== undefined) {
56 + macArm64.set(macArm64Match[1], fileName);
57 + continue;
58 + }
59 + const macX64Match = /^(.+)-mac-x64\.yml$/u.exec(fileName);
60 + if (macX64Match?.[1] !== undefined) {
61 + macX64.set(macX64Match[1], fileName);
62 + continue;
63 + }
64 + const winMatch = /^(.+)-win-(arm64|x64)\.yml$/u.exec(fileName);
65 + if (winMatch?.[1] !== undefined) {
66 + (winMatch[2] === "arm64" ? winArm64 : winX64).set(winMatch[1], fileName);
67 + }
68 + }
69 +
70 + // electron-builder names the macOS arm64 manifest without an arch suffix,
71 + // so the merged macOS feed keeps that name; Windows gets `<channel>.yml`.
72 + return [
73 + ...pairArchitectures("macOS", macArm64, macX64).map(
74 + ({ arm64, x64 }): ReleaseUpdateManifestMerge => ({
75 + platform: "mac",
76 + primary: arm64,
77 + secondary: x64,
78 + output: arm64,
79 + }),
80 + ),
81 + ...pairArchitectures("Windows", winArm64, winX64).map(
82 + ({ channel, arm64, x64 }): ReleaseUpdateManifestMerge => ({
83 + platform: "win",
84 + primary: x64,
85 + secondary: arm64,
86 + output: `${channel}.yml`,
87 + }),
88 + ),
89 + ];
90 +}
91 +
92 +export const mergeReleaseUpdateManifestFiles = Effect.fn("mergeReleaseUpdateManifestFiles")(
93 + function* (releaseAssetsDirArg: string) {
94 + const fs = yield* FileSystem.FileSystem;
95 + const path = yield* Path.Path;
96 + const releaseAssetsDir = path.resolve(releaseAssetsDirArg);
97 + const plans = planReleaseUpdateManifestMerges(yield* fs.readDirectory(releaseAssetsDir));
98 +
99 + yield* Effect.forEach(
100 + plans,
101 + (plan) => {
102 + const primary = path.join(releaseAssetsDir, plan.primary);
103 + const secondary = path.join(releaseAssetsDir, plan.secondary);
104 + const output = path.join(releaseAssetsDir, plan.output);
105 + return mergeUpdateManifestFiles(plan.platform, primary, secondary, output).pipe(
106 + Effect.andThen(
107 + Effect.forEach(
108 + [primary, secondary].filter((source) => source !== output),
109 + (source) => fs.remove(source),
110 + { discard: true },
111 + ),
112 + ),
113 + );
114 + },
115 + { discard: true },
116 + );
117 + },
118 +);
119 +
120 +export const mergeReleaseUpdateManifestsCommand = Command.make(
121 + "merge-release-update-manifests",
122 + {
123 + releaseAssetsDir: Argument.String("release-assets-dir").pipe(
124 + Argument.withDescription("Directory containing every desktop release artifact."),
125 + ),
126 + },
127 + ({ releaseAssetsDir }) => mergeReleaseUpdateManifestFiles(releaseAssetsDir),
128 +).pipe(
129 + Command.withDescription("Require and merge complete arm64/x64 desktop updater manifest pairs."),
130 +);
131 +
132 +if (import.meta.main) {
133 + Command.run(mergeReleaseUpdateManifestsCommand, { version: "0.0.0" }).pipe(
134 + Effect.provide(NodeServices.layer),
135 + NodeRuntime.runMain,
136 + );
137 +}
scripts/release-smoke.ts
+16 -58
@@ -295,33 +295,6 @@ try {
295 );
296
297 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
298 - NodeChildProcess.execFileSync(
299 - process.execPath,
300 - [
301 - NodePath.resolve(repoRoot, "scripts/merge-update-manifests.ts"),
302 - "--platform",
303 - "mac",
304 - arm64Path,
305 - x64Path,
306 - ],
307 - {
308 - cwd: repoRoot,
309 - stdio: "inherit",
310 - },
311 - );
312 -
313 - const mergedManifest = NodeFS.readFileSync(arm64Path, "utf8");
314 - assertContains(
315 - mergedManifest,
316 - "T3-Code-9.9.9-smoke.0-arm64.zip",
317 - "Merged manifest is missing the arm64 asset.",
318 - );
319 - assertContains(
320 - mergedManifest,
321 - "T3-Code-9.9.9-smoke.0-x64.zip",
322 - "Merged manifest is missing the x64 asset.",
323 - );
324 -
298 const { arm64Path: winArm64Path, x64Path: winX64Path } = writeWindowsManifestFixtures(
299 tempRoot,
300 "latest",
@@ -336,38 +309,10 @@ try {
309 const { arm64Path: winDebugArm64Path, x64Path: winDebugX64Path } =
310 writeWindowsBuilderDebugFixtures(tempRoot);
311 NodeChildProcess.execFileSync(
339 - "bash",
312 + process.execPath,
313 [
341 - "-lc",
342 - `
343 - release_assets_dir=${JSON.stringify(NodePath.resolve(tempRoot, "release-assets"))}
344 - shopt -s nullglob
345 - found_windows_manifest=false
346 - for x64_manifest in "$release_assets_dir"/*-win-x64.yml; do
347 - if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
348 - continue
349 - fi
350 -
351 - arm64_manifest="\${x64_manifest/-x64.yml/-arm64.yml}"
352 - output_manifest="\${x64_manifest/-win-x64.yml/.yml}"
353 - if [[ ! -f "$arm64_manifest" ]]; then
354 - echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
355 - exit 1
356 - fi
357 -
358 - found_windows_manifest=true
359 - ${JSON.stringify(process.execPath)} ${JSON.stringify(NodePath.resolve(repoRoot, "scripts/merge-update-manifests.ts"))} --platform win \
360 - "$arm64_manifest" \
361 - "$x64_manifest" \
362 - "$output_manifest"
363 - rm -f "$arm64_manifest" "$x64_manifest"
364 - done
365 -
366 - if [[ "$found_windows_manifest" != true ]]; then
367 - echo "No Windows updater manifests found to merge." >&2
368 - exit 1
369 - fi
370 - `,
314 + NodePath.resolve(repoRoot, "scripts/merge-release-update-manifests.ts"),
315 + NodePath.resolve(tempRoot, "release-assets"),
316 ],
317 {
318 cwd: repoRoot,
@@ -375,6 +320,19 @@ try {
320 },
321 );
322
323 + const mergedManifest = NodeFS.readFileSync(arm64Path, "utf8");
324 + assertContains(
325 + mergedManifest,
326 + "T3-Code-9.9.9-smoke.0-arm64.zip",
327 + "Merged manifest is missing the arm64 asset.",
328 + );
329 + assertContains(
330 + mergedManifest,
331 + "T3-Code-9.9.9-smoke.0-x64.zip",
332 + "Merged manifest is missing the x64 asset.",
333 + );
334 + assertMissing(x64Path, "Release smoke unexpectedly kept the x64 macOS updater manifest.");
335 +
336 const mergedWindowsManifest = NodeFS.readFileSync(mergedWindowsManifestPath, "utf8");
337 assertContains(
338 mergedWindowsManifest,