Skip to content

Commit 891674c

Browse files
authored
Merge pull request #5528 from lidge-jun/codex/main-release-platform-versions
release: fix stable platform packaging
2 parents b730157 + 5a7c48c commit 891674c

4 files changed

Lines changed: 67 additions & 2 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ jobs:
228228
uses: dtolnay/rust-toolchain@02cb101ec7c40f2c49e1d9714d64511d8e1b74de # master
229229
with:
230230
toolchain: stable
231+
targets: ${{ runner.os == 'macOS' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
231232

232233
- name: Install Linux desktop dependencies
233234
if: runner.os == 'Linux'
@@ -336,6 +337,13 @@ jobs:
336337
echo "$description" | grep -q "flags=.*runtime"
337338
echo "$description" | grep -q "Timestamp="
338339
340+
- name: Prepare Windows installer version
341+
if: runner.os == 'Windows'
342+
shell: bash
343+
env:
344+
RELEASE_VERSION: ${{ inputs.version }}
345+
run: bun desktop/scripts/windows-installer-config.ts "$RELEASE_VERSION" "$RUNNER_TEMP/opencodex-msi.json"
346+
339347
# Release signing is intentionally secret-gated. Developer ID, notarization,
340348
# and updater signatures require maintainer-owned credentials; builds without
341349
# those secrets remain useful for local validation but are not release assets.
@@ -353,7 +361,7 @@ jobs:
353361
MACOS_SIGN_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
354362
# linuxdeploy suppresses its own stderr at the default verbosity. Keep
355363
# diagnostics on the first attempt; Apple signing commands stay non-verbose.
356-
run: bunx tauri ${{ runner.os == 'Linux' && '--verbose' || '' }} build --ci --target ${{ matrix.target }} --bundles ${{ matrix.bundles }}
364+
run: bunx tauri ${{ runner.os == 'Linux' && '--verbose' || '' }} build --ci --target ${{ matrix.target }} --bundles ${{ matrix.bundles }} --config "${{ runner.os == 'Windows' && format('{0}/opencodex-msi.json', runner.temp) || '{}' }}"
357365

358366
- name: Rename release assets
359367
shell: bash
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { writeFileSync } from "node:fs";
2+
3+
/** MSI cannot express SemVer prerelease precedence. Keep public application and
4+
* updater versions intact and override only WiX ProductVersion with the core.
5+
* The pinned Tauri template permits equal-core replacement; manual MSI installs
6+
* therefore do not prevent same-core channel downgrades. */
7+
export function windowsInstallerVersion(version: string): string {
8+
if (version.length > 128) throw new Error("Public version exceeds the installer metadata bound");
9+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version);
10+
if (!match || match[4]?.split(".").some(part => /^\d+$/.test(part) && part.length > 1 && part[0] === "0")) {
11+
throw new Error("A valid public SemVer is required for the Windows installer");
12+
}
13+
const parts = [match[1]!, match[2]!, match[3]!].map(Number);
14+
if (parts.some((part, index) => !Number.isSafeInteger(part) || part > (index < 2 ? 255 : 65_535))) {
15+
throw new Error("Windows installer version exceeds MSI numeric limits");
16+
}
17+
return parts.join(".");
18+
}
19+
20+
export function windowsInstallerConfig(version: string) {
21+
return { bundle: { windows: { wix: { version: windowsInstallerVersion(version) } } } };
22+
}
23+
24+
if (import.meta.main) {
25+
const [version, output] = process.argv.slice(2);
26+
if (!version || !output) throw new Error("Usage: windows-installer-config <version> <output.json>");
27+
writeFileSync(output, `${JSON.stringify(windowsInstallerConfig(version))}\n`, { mode: 0o600 });
28+
}

‎structure/ops/docs-and-release.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,3 +522,5 @@ Direct recovery retains the lease until readiness or its bounded deadline. The n
522522
manual-runtime update still prints the existing restart hint.
523523

524524
Linux release bundling enables Tauri verbosity on the primary attempt so linuxdeploy diagnostics remain visible. macOS signing verbosity and publication/signature gates are unchanged.
525+
526+
Universal macOS release builds install both aarch64-apple-darwin and x86_64-apple-darwin Rust targets. Windows builds consume the private JSON override generated by `desktop/scripts/windows-installer-config.ts`: only WiX ProductVersion uses the validated numeric public version core. Public package/application versions, tags, asset names and updater manifests retain full SemVer. The pinned Tauri MSI template permits equal-core replacement; manual MSI installation does not enforce same-core preview/stable downgrade prevention.

‎tests/ci-workflows/release-desktop-scripts.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { windowsInstallerConfig, windowsInstallerVersion } from "../../desktop/scripts/windows-installer-config";
12
import { describe, expect, test } from "bun:test";
23
import { createHash, generateKeyPairSync, sign as ed25519Sign } from "node:crypto";
34
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -27,6 +28,17 @@ function temporaryDirectory(): string {
2728
}
2829

2930
describe("desktop release scripts", () => {
31+
test("MSI uses numeric core while public SemVer metadata remains external", () => {
32+
for (const version of ["2.61.0", "2.61.0-preview.20260922", "2.61.0-preview.20260922.1+build.7"]) {
33+
expect(windowsInstallerVersion(version)).toBe("2.61.0");
34+
expect(windowsInstallerConfig(version)).toEqual({ bundle: { windows: { wix: { version: "2.61.0" } } } });
35+
}
36+
expect(windowsInstallerVersion("255.255.65535")).toBe("255.255.65535");
37+
for (const version of ["256.1.0", "1.256.0", "1.1.65536", "2.01.0", "2.1.0-01", "v2.1.0", "2.1", "2.1.0;evil", "999999999999999999.0.0"]) {
38+
expect(() => windowsInstallerVersion(version)).toThrow();
39+
}
40+
});
41+
3042
test("renames macOS DMG and updater archive and copies signatures", () => {
3143
const root = temporaryDirectory();
3244
try {
@@ -405,7 +417,7 @@ describe("widget extension signing", () => {
405417
) as {
406418
jobs?: Record<string, {
407419
env?: Record<string, string>;
408-
steps?: Array<{ name?: string; if?: string; run?: string; env?: Record<string, string> }>;
420+
steps?: Array<{ name?: string; if?: string; run?: string; env?: Record<string, string>; with?: Record<string, string> }>;
409421
}>;
410422
};
411423
const steps = workflow.jobs?.["package-desktop"]?.steps ?? [];
@@ -417,6 +429,21 @@ describe("widget extension signing", () => {
417429
const indexOfStepRunning = (fragment: string) =>
418430
steps.findIndex(step => typeof step.run === "string" && step.run.includes(fragment));
419431

432+
test("release prepares both Mac architectures and wires only the MSI metadata override", () => {
433+
const rust = steps.find(step => step.name === "Setup Rust");
434+
expect(rust?.with?.targets).toContain("aarch64-apple-darwin,x86_64-apple-darwin");
435+
expect(rust?.with?.targets).toContain("runner.os == 'macOS'");
436+
const prepare = steps.find(step => step.name === "Prepare Windows installer version");
437+
expect(prepare?.if).toBe("runner.os == 'Windows'");
438+
expect(prepare?.env?.RELEASE_VERSION).toBe("${{ inputs.version }}");
439+
expect(prepare?.run).toContain('windows-installer-config.ts "$RELEASE_VERSION" "$RUNNER_TEMP/opencodex-msi.json"');
440+
const build = steps.find(step => step.name === "Build desktop bundles");
441+
expect(build?.run).toContain("--config");
442+
expect(build?.run).toContain("format('{0}/opencodex-msi.json', runner.temp)");
443+
expect(build?.run).toContain("runner.os == 'Windows'");
444+
expect(indexOfStep("Prepare Windows installer version")).toBeLessThan(indexOfStep("Build desktop bundles"));
445+
});
446+
420447
test("the release build hands the widget a signing identity and forbids an ad-hoc fallback", () => {
421448
const build = steps.find(step => step.name === "Build WidgetKit extension");
422449
expect(build).toBeDefined();

0 commit comments

Comments
 (0)