Fix CLI release version fallback#898
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves CodexBarCLI --version for standalone CLI distributions by adding a fallback that reads a VERSION file located next to the executable, and ensures release artifacts include that file so the correct release version is reported outside of CodexBar.app.
Changes:
- Add
VERSION-file fallback inCodexBarCLI.currentVersion(...)when the executable isn’t inside a.appbundle. - Extend CLI entry tests to cover the new fallback behavior.
- Update the release CLI workflow to include
VERSIONin packaged tarballs and validate--versionvia the fallback during smoke testing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Tests/CodexBarTests/CLIEntryTests.swift | Adds a test verifying --version can be derived from an adjacent VERSION file. |
| Sources/CodexBarCLI/CLIIO.swift | Adds logic to read and normalize a VERSION file next to the resolved executable when .app detection fails. |
| .github/workflows/release-cli.yml | Writes VERSION for smoke tests and includes it in the release tarball contents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| guard let executablePath, !executablePath.isEmpty else { return nil } | ||
|
|
||
| let executableURL = URL(fileURLWithPath: executablePath).resolvingSymlinksInPath() | ||
| return Self.containingAppVersion(for: executableURL) | ||
| if let version = Self.containingAppVersion(for: executableURL) { | ||
| return version | ||
| } | ||
| return Self.adjacentVersionFileVersion(for: executableURL) |
Co-authored-by: Thiago Costa <thiago12_fera@hotmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7969fba5b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let executableURL = URL(fileURLWithPath: executablePath).resolvingSymlinksInPath() | ||
| return Self.containingAppVersion(for: executableURL) | ||
| if let version = Self.containingAppVersion(for: executableURL) { | ||
| return version | ||
| } | ||
| return Self.adjacentVersionFileVersion(for: executableURL) |
There was a problem hiding this comment.
Resolve executable path before reading adjacent VERSION
When the CLI is launched via PATH (for example, user runs codexbar), CommandLine.arguments.first can be just the program name rather than an absolute path. In that case URL(fileURLWithPath: executablePath) points to the current working directory, so the new fallback reads ./VERSION and may report an unrelated repo/project version instead of CodexBar’s release version. This regression is introduced by adding adjacentVersionFileVersion without first resolving argv[0] to the real executable location.
Useful? React with 👍 / 👎.
7969fba to
130b749
Compare
Summary
VERSIONfile fallback forCodexBarCLI --versionwhen the binary is not insideCodexBar.app.VERSIONin release CLI tarballs so downloaded standalonecodexbar/CodexBarCLIassets report the release version.Validation
git diff --check HEAD~1..HEADNot run locally:
swift test --filter CLIEntryTestsbecause Swift is not installed in this Windows environment.