Skip to content

feat(cli): inject version from build instead of hardcoding - #494

Merged
16bit-ykiko merged 3 commits into
mainfrom
feat/version-injection
Jul 7, 2026
Merged

16bit-ykiko merged 3 commits into
mainfrom
feat/version-injection

Conversation

@16bit-ykiko

@16bit-ykiko 16bit-ykiko commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

Replaces the hardcoded "0.1.0" version strings with a build-time injected version, so clice --version and the LSP ServerInfo always match the release tag.

How it works

  • A CMake custom target regenerates generated/version.h on every build from git describe --tags --always --dirty; the write is elided when the content is unchanged, so nothing rebuilds spuriously.
  • Tag-exact builds (the release pipeline checks out the tag) embed the tag itself, v prefix stripped: a v1.0.0-beta.1 tag builds a binary that reports 1.0.0-beta.1.
  • Between tags the version carries the distance and commit (0.1.0-alpha.4-109-g41b8c3f, plus -dirty for local modifications). A checkout with no reachable tag reports the base version plus commit hash; a non-git build (source tarball) falls back to the CMake project version, now declared as project(... VERSION 0.1.0 ...). Bumping the base for a release is that one line.
  • Both consumers — the --version CLI and the initialize response's ServerInfo — read the same clice::version constant.

Notes

  • CI branch builds use shallow, tagless checkouts, so they embed 0.1.0+g<hash>; the tag-triggered release workflow checks out the tag ref and gets the exact version. This only affects what dev builds print.
  • The integration test no longer pins a literal version: it asserts the LSP handshake and clice --version report the same string, which stays true regardless of tag state and locks the two paths together.

Verification

  • Built and ran ./clice --version (prints the current describe output).
  • Unit tests (850) green, tests/integration/features/test_server.py green including the new cross-check, smoke tests 3/3.
  • Rebuild after a no-op change only re-runs the version generator; no recompilation.

Summary by CodeRabbit

  • New Features

    • Build-time version information is now derived from the current source state (including tagged and dirty states).
    • The app’s --version output and the server’s reported version are kept consistent across runtime and LSP.
  • Bug Fixes

    • Improved build reliability by ensuring version data is generated before the app and test suites run, especially in parallel builds.
  • Tests

    • Integration tests now validate the server’s reported version against the executable’s --version output instead of using a fixed value.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 74b2edef-7cbb-409e-b55d-db2033144d91

📥 Commits

Reviewing files that changed from the base of the PR and between db59437 and ec3110d.

📒 Files selected for processing (1)
  • cmake/generate_version.cmake
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmake/generate_version.cmake

📝 Walkthrough

Walkthrough

Adds build-time version generation from git metadata, generates a header exposing the version string, wires build dependencies for the generated header, and updates the CLI, LSP server info, and integration test to use and verify the generated version.

Changes

Dynamic Version Generation

Layer / File(s) Summary
Version generation script and template
cmake/generate_version.cmake, cmake/version.h.in
A new CMake script resolves a version string from git metadata with fallback handling and writes it into a generated header template exposing clice::version.
Build target wiring
CMakeLists.txt
Declares an explicit project VERSION, adds a generate_version_header custom target producing generated/version.h, and adds build dependencies so clice-core, clice, and unit_tests wait on it.
Consumers use generated version
src/clice.cc, src/server/transport/lsp_client.cpp, tests/integration/features/test_server.py
The CLI --version output and LSP ServerInfo::version now use clice::version; the integration test validates the reported version against the executable's --version output.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: moving version info from hardcoded values to build-injected output.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/version-injection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db59437286

ℹ️ 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".

Comment thread cmake/generate_version.cmake Outdated
@16bit-ykiko
16bit-ykiko merged commit 65f8bd5 into main Jul 7, 2026
22 checks passed
@16bit-ykiko
16bit-ykiko deleted the feat/version-injection branch July 17, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant