Derive version from git tag and publish to PyPI via OIDC - #257
Merged
Conversation
Replace the broken sed/commit-back release flow with tag-driven versioning: - pyproject.toml: build with hatch-vcs, version sourced from the git tag (source = "vcs"); drop the _version.py path source. - Remove _version.py; system_config resolves the version from package metadata, falling back to the highest git tag for source checkouts. - publish-to-pypi.yml: release-triggered only, least-privilege permissions, and publish via PyPI Trusted Publishing (OIDC) using pypa/gh-action-pypi-publish instead of a long-lived API token.
pedjaradenkovic
approved these changes
Jul 23, 2026
pedjaradenkovic
left a comment
Contributor
There was a problem hiding this comment.
I think this is good to go!
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
Fixes the failing PyPI publish workflow and makes releases fully tag-driven.
Previously the workflow tried to
sedaversion =line intopyproject.tomlthat didn't exist (the version wasdynamic), thengit commited with nothing staged — which failed the job. This replaces that with a clean, conventional setup.Changes
pyproject.toml— build withhatch-vcs; the version is sourced from the git tag ([tool.hatch.version] source = "vcs"). Removed the_version.pypath source._version.py— deleted. No longer stored in the repo; the version comes from the git tag at build time.system_config.py—client_versionnow resolves from installed package metadata (importlib.metadata), falling back to the highest git tag for uninstalled source checkouts..github/workflows/publish-to-pypi.yml—workflow_dispatch/version-input path),permissions(top-level{}, opt-in per job),pypa/gh-action-pypi-publishinstead of a long-livedPYPI_API_TOKEN.The PyPI Trusted Publisher (owner
Codeplain-ai, repocodeplain, workflowpublish-to-pypi.yml, environmentpypi) is already registered.Release procedure after this merges
Publish a GitHub Release with tag
vX.Y.Z(higher than what's on PyPI) → the workflow builds with that version and publishes to PyPI. No secrets, no manual version bumps.Verification
uv buildon a clean tag checkout produces the exact tag version (verified end-to-end).pip installof the built wheel →codeplain --versionreports the correct version (via package metadata).black,isort,flake8,mypy, and the test suite all pass.Testing recommendation
Cut a pre-release
vX.Y.Zrc1first (marked pre-release) to exercise the full OIDC pipeline without affecting normalpip installusers.