Derive the version from git tags (hatch-vcs) - #9
Merged
Conversation
Releasing no longer requires bumping pyproject.toml and __version__ by hand — the tag is the single source of truth: - pyproject: dynamic version via hatch-vcs. - __init__: __version__ from importlib.metadata, with a dev fallback for uninstalled source trees. - release.yml: drop the now-impossible tag/version mismatch guard; fetch-depth: 0 so hatch-vcs can see tags. - ci.yml: fetch-depth: 0, and mark the mounted repo safe for git inside the manylinux container. - RELEASING.md: releasing is now just pushing a tag. Verified locally: editable install resolves 0.1.3.dev0+g... past the v0.1.2 tag, wheel build gets the same version, uninstalled source tree falls back to 0.0.0.dev0, all 5 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SQbVkPEprK2ebcjck5ouUy
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Moves the project to VCS-derived versioning (hatch-vcs) so releases come from v* tags and runtime __version__ reflects installed package metadata.
Changes:
- Switch
pyproject.tomltodynamic = ["version"]withhatch-vcsas the version source. - Read
__version__from installed distribution metadata with a dev fallback when running from source. - Update CI/release workflows to fetch full git history for hatch-vcs and adjust release documentation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/gomc_rest/init.py | Reads version from installed package metadata instead of a hardcoded string. |
| pyproject.toml | Enables hatch-vcs and dynamic versioning derived from git tags. |
| RELEASING.md | Updates release steps to tag-based releases with no manual version bumps. |
| .github/workflows/release.yml | Fetches full git history and removes tag-vs-version check (now VCS-derived). |
| .github/workflows/ci.yml | Fetches full git history for hatch-vcs and tweaks container smoke test for git safety. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| PLCClient, | ||
| ) | ||
|
|
||
| from importlib.metadata import PackageNotFoundError, version as _pkg_version |
Comment on lines
+36
to
+39
| try: | ||
| __version__ = _pkg_version("gomc-rest") | ||
| except PackageNotFoundError: # running from a source tree without install | ||
| __version__ = "0.0.0.dev0" |
Comment on lines
41
to
43
| PY=/opt/python/cp311-cp311/bin/python | ||
| git config --global --add safe.directory /w && | ||
| "$PY" -m pip install -e . pytest && |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Releasing no longer requires editing
pyproject.tomland__version__by hand — the git tag is the single source of truth. Cutting a release is now literally:git tag v0.2.0 && git push origin v0.2.0Changes
pyproject.toml:dynamic = ["version"]+[tool.hatch.version] source = "vcs"(hatch-vcs added to build requires).src/gomc_rest/__init__.py:__version__reads the installed package metadata; falls back to0.0.0.dev0when run from an uninstalled source tree.release.yml: removed the tag/project.versionmismatch guard (a mismatch is now impossible);fetch-depth: 0so hatch-vcs can see tags.ci.yml:fetch-depth: 0;git config safe.directoryfor the mounted repo inside the manylinux container.RELEASING.md: updated — releasing is just pushing a tag; untagged builds getX.Y.Z.devN+g...versions.Verified locally
v0.1.2tag resolves0.1.3.dev0+g...(correct next-patch dev semantics); a clean build at a tag yields the exact tag version.0.0.0.dev0.🤖 Generated with Claude Code
Generated by Claude Code