Skip to content

build: derive the project version from the newest git tag - #876

Merged
tschm merged 1 commit into
mainfrom
dynamic-versioning
Sep 8, 2026
Merged

tschm merged 1 commit into
mainfrom
dynamic-versioning

Conversation

@tschm

@tschm tschm commented Sep 8, 2026

Copy link
Copy Markdown
Member

Derive [project].version from the newest git tag instead of writing it into pyproject.toml.

  • dynamic = ["version"] in [project], hatch-vcs added to the build requires, and [tool.hatch.version] source = "vcs".
  • uv.lock loses its root-package version line: uv omits the field entirely for a dynamic root, so there is no per-commit churn.
  • [tool.bumpversion] stays. With no written number it reads the newest tag via git describe — the same source hatch-vcs builds from, so the bump it offers and the version it produces cannot disagree. Its comment is updated to say so.

Why this is safe here:

  • The declared version already equalled the newest tag, so nothing changes about what the next release publishes.
  • rhiza_release.yml is already built for VCS-derived versions: every job checks out with fetch-depth: 0, and after uv build it verifies the built distribution's filename against the tag — the one place a derived version can be caught being wrong.
  • __version__ is resolved through importlib.metadata at import time, so runtime versioning is unaffected.
  • pytest-rhiza's test_pyproject (0.6.0, the rhiza-task@1.7.0 default) tolerates a dynamic version: 22 pass, 6 skip with a stated reason.

Verified locally: uv lock, uv build (produces the expected .devN+g<sha> off-tag version), the rhiza pyproject checks, and the version/metadata tests.

No gates beyond those were run — CI is the check.

[project].version was a written number that had to be kept in step with the
tag by hand. hatch-vcs derives it from `git describe` instead, so the two
cannot drift: the number lives in one place.

uv omits the version field for a dynamic root package, so uv.lock loses its
own version line and does not churn per commit. [tool.bumpversion] stays and
falls back to the newest tag, which is the same source the build reads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tschm
tschm merged commit 485c53b into main Sep 8, 2026
58 checks passed
@tschm
tschm deleted the dynamic-versioning branch September 8, 2026 08:11
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