-
Notifications
You must be signed in to change notification settings - Fork 4
fix(version): Use versioned dev versions #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| --- | ||
|
|
||
| Unversioned builds now report a version embedded from their source checkout (`3.0.0-dev.20260803.f51f1e4`, plus `.dirty` for an unclean tree) instead of a flat `0.0.0-dev`. Dev-only: release binaries are compiled with an explicit version, so published behavior is unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import cliPackage from "../../../cli/package.json"; | ||
|
|
||
| const DEV_TAG = "dev"; | ||
|
|
||
| type GitResult = { | ||
| exitCode: number; | ||
| stdout: string; | ||
| }; | ||
|
|
||
| function git(args: string[]): GitResult | undefined { | ||
| try { | ||
| // Anchor the lookup on this source file rather than the user's current | ||
| // directory. Bun executes this module from the real checkout while it | ||
| // transpiles or bundles the CLI. | ||
| const process = Bun.spawnSync(["git", "--no-optional-locks", "-C", import.meta.dir, ...args], { | ||
| stdio: ["ignore", "pipe", "pipe"], | ||
| }); | ||
| return { exitCode: process.exitCode, stdout: process.stdout.toString().trim() }; | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| function describeCheckout(): string | undefined { | ||
| const head = git(["log", "-1", "--format=%cs %h"]); | ||
| if (!head || head.exitCode !== 0) return undefined; | ||
|
|
||
| const [date, sha] = head.stdout.split(" "); | ||
| if (!date || !sha) return undefined; | ||
|
|
||
| // Semver forbids leading zeroes in an all-numeric prerelease identifier. The | ||
| // `g` prefix is the same escape used by git-describe. | ||
| const commit = /^0\d*$/.test(sha) ? `g${sha}` : sha; | ||
|
|
||
| // Include untracked files because a build can consume source that the commit | ||
| // does not describe. | ||
| const status = git(["status", "--porcelain", "--untracked-files=normal"]); | ||
| const dirty = status?.exitCode === 0 && status.stdout !== "" ? ".dirty" : ""; | ||
|
|
||
| return `${date.replaceAll("-", "")}.${commit}${dirty}`; | ||
| } | ||
|
|
||
| /** | ||
| * Resolve the checkout-derived development version during Bun transpilation. | ||
| * | ||
| * Bun inlines the returned string at each macro call, so compiled binaries do | ||
| * not execute Git commands at runtime. | ||
| */ | ||
| export function resolveDevVersionAtBuildTime(): string { | ||
| const checkout = describeCheckout(); | ||
| return `${cliPackage.version}-${DEV_TAG}${checkout ? `.${checkout}` : ""}`; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Document the no-Git fallback.
When Git is unavailable or the CLI runs outside a checkout, the version falls back to
<version>-devwithout the date, SHA, or.dirtysuffix. Add this case so the documentation matches the supported version-resolution behavior.Proposed documentation update
The `dev` and `start` commands do not inject a version, so a Bun macro derives and inlines a dev version while transpiling or compiling the CLI: `<version in packages/cli/package.json>-dev.<YYYYMMDD>.<short sha>`, suffixed `.dirty` for an unclean tree. A local `build:compile:all` rehearsal leaves `CLI_VERSION` undefined and uses the same macro, so every binary retains the commit it was built from without running Git at runtime. The release workflow always passes an explicit `--version`, which replaces the macro fallback during compilation. + If Git is unavailable or the CLI is not running from a checkout, the macro falls back to `<version in packages/cli/package.json>-dev`.📝 Committable suggestion
🤖 Prompt for AI Agents