Skip to content

Derive the version from git tags (hatch-vcs) - #9

Merged
Moge800 merged 1 commit into
mainfrom
claude/wizardly-allen-lnrqxf
Jul 6, 2026
Merged

Derive the version from git tags (hatch-vcs)#9
Moge800 merged 1 commit into
mainfrom
claude/wizardly-allen-lnrqxf

Conversation

@Moge800

@Moge800 Moge800 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Releasing no longer requires editing pyproject.toml and __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.0

Changes

  • 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 to 0.0.0.dev0 when run from an uninstalled source tree.
  • release.yml: removed the tag/project.version mismatch guard (a mismatch is now impossible); fetch-depth: 0 so hatch-vcs can see tags.
  • ci.yml: fetch-depth: 0; git config safe.directory for the mounted repo inside the manylinux container.
  • RELEASING.md: updated — releasing is just pushing a tag; untagged builds get X.Y.Z.devN+g... versions.

Verified locally

  • Editable install past the v0.1.2 tag resolves 0.1.3.dev0+g... (correct next-patch dev semantics); a clean build at a tag yields the exact tag version.
  • Wheel filename carries the derived version.
  • Uninstalled source tree falls back to 0.0.0.dev0.
  • All 5 tests pass.

🤖 Generated with Claude Code


Generated by Claude Code

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
Copilot AI review requested due to automatic review settings July 6, 2026 12:15

Copilot AI 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.

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.toml to dynamic = ["version"] with hatch-vcs as 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.

Comment thread src/gomc_rest/__init__.py
PLCClient,
)

from importlib.metadata import PackageNotFoundError, version as _pkg_version
Comment thread src/gomc_rest/__init__.py
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 thread .github/workflows/ci.yml
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 &&
@Moge800
Moge800 merged commit 98e1e58 into main Jul 6, 2026
2 of 3 checks passed
@Moge800
Moge800 deleted the claude/wizardly-allen-lnrqxf branch July 6, 2026 12:20
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.

3 participants