feat: embed git SHA in version string #110

Merged
razvandimescu merged 2 commits from feat/build-version into main 2026-04-16 18:41:23 +08:00
razvandimescu commented 2026-04-16 18:03:05 +08:00 (Migrated from github.com)

Summary

Follow-up to #109. Addresses #108's request to distinguish release builds from source/AUR/main-branch builds.

  • Adds build.rs (~40 LOC) that runs git describe --tags --always --dirty at compile time and sets NUMA_BUILD_VERSION as a rustc env var.
  • New numa::version() function returns the build version everywhere: CLI (numa --version), dashboard header, /stats endpoint, /health endpoint.
  • Falls back to CARGO_PKG_VERSION when git is unavailable (source tarballs, Docker builds without .git).
  • Replaces all 6 inline env!("CARGO_PKG_VERSION") call sites with the single version() function.
  • No new crate dependencies.

Version strings by build context:

Context Output
Tagged release (v0.13.1) 0.13.1
Commits ahead of tag 0.13.1+a87f907
Uncommitted changes 0.13.1+a87f907-dirty
No git (tarball, Docker) 0.13.1

Test plan

  • make all — fmt + clippy + audit + 285 tests pass
  • numa --version on current branch → 0.13.1+0118ab0-dirty (commits ahead + dirty)
  • Build with .git removed → falls back to 0.13.1 (no crash, no build error)
  • build.rs re-runs on git HEAD change (tracked via cargo:rerun-if-changed)
## Summary Follow-up to #109. Addresses #108's request to distinguish release builds from source/AUR/main-branch builds. - Adds `build.rs` (~40 LOC) that runs `git describe --tags --always --dirty` at compile time and sets `NUMA_BUILD_VERSION` as a rustc env var. - New `numa::version()` function returns the build version everywhere: CLI (`numa --version`), dashboard header, `/stats` endpoint, `/health` endpoint. - Falls back to `CARGO_PKG_VERSION` when git is unavailable (source tarballs, Docker builds without `.git`). - Replaces all 6 inline `env!("CARGO_PKG_VERSION")` call sites with the single `version()` function. - No new crate dependencies. Version strings by build context: | Context | Output | |---|---| | Tagged release (`v0.13.1`) | `0.13.1` | | Commits ahead of tag | `0.13.1+a87f907` | | Uncommitted changes | `0.13.1+a87f907-dirty` | | No git (tarball, Docker) | `0.13.1` | ## Test plan - [x] `make all` — fmt + clippy + audit + 285 tests pass - [x] `numa --version` on current branch → `0.13.1+0118ab0-dirty` (commits ahead + dirty) - [x] Build with `.git` removed → falls back to `0.13.1` (no crash, no build error) - [x] `build.rs` re-runs on `git HEAD` change (tracked via `cargo:rerun-if-changed`)
Sign in to join this conversation.