Skip to content

Commit 97cdef3

Browse files
authored
Merge pull request #15 from codebase/codex/release-binary-version
fix(release): embed native binary version
2 parents b9c1e07 + 4ceba76 commit 97cdef3

4 files changed

Lines changed: 17 additions & 27 deletions

File tree

.github/workflows/build-binaries.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ jobs:
7878
# other targets are cross-compiled — we trust bun's compile output
7979
# for them and verify post-release.
8080
if: matrix.target == 'bun-linux-x64-modern'
81-
run: ./${{ matrix.asset }} --version || true
81+
run: |
82+
EXPECTED="$(node -p "require('./package.json').version")"
83+
ACTUAL="$(./${{ matrix.asset }} --version)"
84+
test "${ACTUAL}" = "${EXPECTED}"
8285
8386
- name: Upload to GitHub release
8487
env:
@@ -149,5 +152,9 @@ jobs:
149152
# needing real credentials.
150153
shell: pwsh
151154
run: |
152-
./codebase.exe --version
155+
$expected = node -p "require('./package.json').version"
156+
$actual = ./codebase.exe --version
157+
if ($actual.Trim() -ne $expected.Trim()) {
158+
throw "Version mismatch: expected $expected, got $actual"
159+
}
153160
./codebase.exe --help

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codebase-cli",
3-
"version": "2.0.0-pre.84",
3+
"version": "2.0.0-pre.85",
44
"description": "Codebase CLI — a TypeScript coding agent on the pi-mono runtime. OAuth-aware, any LLM provider, single install.",
55
"keywords": [
66
"ai",

src/version.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
1-
import { readFileSync } from "node:fs";
2-
import { dirname, join } from "node:path";
3-
import { fileURLToPath } from "node:url";
1+
import packageMetadata from "../package.json";
42

53
/**
6-
* Resolves the running CLI's version at runtime by reading the bundled
7-
* package.json. This is the single source of truth for "what am I
8-
* running" — surfaced in the welcome banner, the status bar, and the
9-
* `--version` flag so the user can never wonder again whether their
10-
* shell is launching the build they just compiled.
11-
*
12-
* Fallback to "?.?.?" if the lookup fails for any reason; a missing
13-
* version string shouldn't crash the agent.
4+
* Keep package.json as the single source of truth, but import it so native
5+
* Bun builds embed the version instead of trying to read a neighboring file
6+
* that does not exist beside a standalone binary.
147
*/
15-
export const VERSION: string = (() => {
16-
try {
17-
// dist/version.js → dist/ → package.json
18-
// src/version.ts (via tsx) → src/ → package.json
19-
const here = dirname(fileURLToPath(import.meta.url));
20-
const pkg = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8")) as { version?: string };
21-
return pkg.version ?? "?.?.?";
22-
} catch {
23-
return "?.?.?";
24-
}
25-
})();
8+
export const VERSION = packageMetadata.version;

0 commit comments

Comments
 (0)