Skip to content

Commit e4a85d1

Browse files
committed
fix(release): stop dev from carrying a version behind its own releases
dev accumulated 254 commits without touching package.json, so its version string (2.32.1-preview.20260825) ended up BEHIND the published latest dist-tag (2.33.0) once v2.33.0 was cut from main. One stale line, two failure modes: - assertChannelVersionMovesForward refuses the string as a channel regression, so a release cut from this tree cannot publish at all. - merging dev into main resolves package.json to main's side, yielding a tree that claims to be the already-published 2.33.0 - a silent duplicate rather than a loud failure. 2.34.0 is the target: npm returns E404 for it, no v2.34.0 tag exists, and it moves latest forward. Minor rather than patch follows the precedent in 32529c2 - the range carries new providers, new config surfaces, GUI work and adapter contract changes, not only fixes. The regression test is the part that lasts. 32529c2 repaired this same condition by hand and nothing has enforced it since. tests/release-version-line asserts the in-tree version is strictly ahead of the highest local release tag, and was driven red against the exact string dev carried before this commit. It reads local tags rather than the npm registry so it needs no network and no edit per release, and reports nothing when no tags are present, because actions/checkout fetches none by default and an empty set cannot prove a regression. It imports compareReleaseTags from scripts/release-notes rather than scripts/release: the latter parses process.argv and calls process.exit at module scope, so importing it from a test kills the runner. This does not publish, tag, or promote. scripts/release.ts still refuses to run anywhere but main/preview.
1 parent 9919438 commit e4a85d1

2 files changed

Lines changed: 98 additions & 1 deletion

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitkyc08/opencodex",
3-
"version": "2.32.1-preview.20260825",
3+
"version": "2.34.0",
44
"description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
55
"type": "module",
66
"main": "./bin/package-main.mjs",

‎tests/release-version-line.test.ts‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { describe, expect, test } from "bun:test";
2+
import { readFileSync } from "node:fs";
3+
import { fileURLToPath } from "node:url";
4+
import { compareReleaseTags } from "../scripts/release-notes";
5+
6+
const repoRoot = fileURLToPath(new URL("../", import.meta.url));
7+
8+
/**
9+
* The in-tree version must never sit BEHIND a version this repository has already
10+
* released.
11+
*
12+
* This is not hypothetical. dev accumulated 254 commits without ever touching
13+
* package.json, so its version string (2.32.1-preview.20260825) fell behind the
14+
* published latest dist-tag (2.33.0) once v2.33.0 was cut from main. One stale line,
15+
* two distinct failure modes:
16+
*
17+
* - assertChannelVersionMovesForward in scripts/release.ts refuses the string as a
18+
* channel regression, so a release cut from that tree cannot publish at all.
19+
* - merging dev into main resolves package.json to main's side, producing a tree that
20+
* claims to be the ALREADY-PUBLISHED 2.33.0 - a silent duplicate instead of a loud
21+
* failure.
22+
*
23+
* Commit 32529c2b2 repaired precisely this by hand once, and nothing has enforced it
24+
* since. The assertion reads the local tag set rather than the npm registry, so it needs
25+
* no network and no edit at each release.
26+
*
27+
* compareReleaseTags comes from scripts/release-notes and not from scripts/release: the
28+
* latter parses process.argv and calls process.exit at module scope, so importing it from
29+
* a test kills the runner. release-notes guards its CLI behind import.meta.main.
30+
*/
31+
32+
/** Release tags shaped vX.Y.Z[-pre]. Non-release tags are ignored, not an error. */
33+
const RELEASE_TAG = /^v\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
34+
35+
function localReleaseTags(): string[] {
36+
const result = Bun.spawnSync(["git", "tag", "--list", "v*"], { cwd: repoRoot });
37+
// A tarball install, a shallow CI checkout, or a missing git binary all land here.
38+
// Absent tags cannot prove a regression, so the check reports nothing rather than
39+
// inventing a failure.
40+
if (result.exitCode !== 0) return [];
41+
return new TextDecoder()
42+
.decode(result.stdout)
43+
.split("\n")
44+
.map((line) => line.trim())
45+
.filter((line) => RELEASE_TAG.test(line));
46+
}
47+
48+
function inTreeVersion(): string {
49+
const raw = readFileSync(new URL("../package.json", import.meta.url), "utf8");
50+
const version = (JSON.parse(raw) as { version?: unknown }).version;
51+
if (typeof version !== "string") throw new Error("package.json has no string version");
52+
return version;
53+
}
54+
55+
/** Newest tag by SemVer precedence, or null when the set is empty. */
56+
function highestReleaseTag(tags: string[]): string | null {
57+
if (tags.length === 0) return null;
58+
const sorted = [...tags].sort(compareReleaseTags);
59+
return sorted[sorted.length - 1] ?? null;
60+
}
61+
62+
describe("release version line", () => {
63+
test("package.json carries a parseable SemVer version", () => {
64+
expect(inTreeVersion()).toMatch(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/);
65+
});
66+
67+
test("the in-tree version is strictly ahead of every tagged release", () => {
68+
const tags = localReleaseTags();
69+
if (tags.length === 0) {
70+
// Shallow checkout: actions/checkout fetches no tags by default. Reporting nothing
71+
// keeps this honest instead of asserting against an empty set that always passes.
72+
expect(tags).toEqual([]);
73+
return;
74+
}
75+
76+
const version = inTreeVersion();
77+
const highest = highestReleaseTag(tags);
78+
expect(highest).not.toBeNull();
79+
80+
const ordering = compareReleaseTags("v" + version, highest!);
81+
expect(
82+
ordering,
83+
"package.json version " + version + " is not ahead of the highest release tag " +
84+
highest +
85+
". A release cut from this tree is either rejected as a channel regression or " +
86+
"silently republishes an already-published version. Bump package.json.",
87+
).toBeGreaterThan(0);
88+
});
89+
90+
test("a version behind the tag set is detected rather than tolerated", () => {
91+
// Proves the comparison above is not vacuous: the same helper, given the exact string
92+
// dev actually carried, must order it BEHIND the release that stranded it.
93+
expect(compareReleaseTags("v2.32.1-preview.20260825", "v2.33.0")).toBeLessThan(0);
94+
expect(compareReleaseTags("v2.33.0", "v2.33.0")).toBe(0);
95+
expect(compareReleaseTags("v2.34.0", "v2.33.0")).toBeGreaterThan(0);
96+
});
97+
});

0 commit comments

Comments
 (0)