Fix PyPI release pipeline with dynamic versioning from git tags#6
Fix PyPI release pipeline with dynamic versioning from git tags#6
Conversation
Co-authored-by: rgregg <[email protected]>
Co-authored-by: rgregg <[email protected]>
Co-authored-by: rgregg <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR fixes the PyPI release pipeline by replacing the hardcoded version 0.1.0 with dynamic versioning using setuptools-scm. The issue occurred because every release attempt uploaded the same version number regardless of the git tag, causing "File already exists" errors on PyPI.
Changes:
- Replaced hardcoded version with setuptools-scm for automatic version derivation from git tags
- Updated CI workflow to fetch full git history for version detection
- Added documentation for the versioning workflow and release process
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyproject.toml | Added setuptools-scm configuration with tag regex supporting -alpha, -beta, and -rc suffixes; set version as dynamic |
| src/meshcore_proxy/init.py | Replaced static version string with dynamic import from package metadata using importlib.metadata |
| .github/workflows/ci.yml | Added fetch-depth: 0 to build job checkout to enable setuptools-scm git tag detection |
| README.md | Added Development section documenting versioning workflow, release process, and version resolution examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| __version__ = version("meshcore-proxy") | ||
| except PackageNotFoundError: | ||
| # Package is not installed | ||
| __version__ = "0.0.0.dev0" |
There was a problem hiding this comment.
The new dynamic version resolution logic lacks test coverage. Since this project has comprehensive test coverage for other modules (test_cli.py and test_proxy.py), consider adding a test to verify that the version attribute is correctly set. The test should verify both the successful case (when the package is installed) and the fallback case (when PackageNotFoundError is raised).
|
|
||
| This project uses [setuptools-scm](https://github.com/pypa/setuptools-scm) for automatic versioning based on git tags. | ||
|
|
||
| **Version format:** Tags should follow the pattern `vX.Y.Z` or `vX.Y.Z-alpha` (e.g., `v0.4.0`, `v0.4.0-alpha`) |
There was a problem hiding this comment.
The documentation mentions tags can follow the pattern vX.Y.Z or vX.Y.Z-alpha, but the tag regex also accepts -beta and -rc[0-9]+ suffixes. The documentation should be updated to mention all supported tag formats for completeness. Consider updating line 336 to say: "Tags should follow the pattern vX.Y.Z, vX.Y.Z-alpha, vX.Y.Z-beta, or vX.Y.Z-rc<number> (e.g., v0.4.0, v0.4.0-alpha, v0.4.0-beta, v0.4.0-rc1)"
| **Version format:** Tags should follow the pattern `vX.Y.Z` or `vX.Y.Z-alpha` (e.g., `v0.4.0`, `v0.4.0-alpha`) | |
| **Version format:** Tags should follow the pattern `vX.Y.Z`, `vX.Y.Z-alpha`, `vX.Y.Z-beta`, or `vX.Y.Z-rc<number>` (e.g., `v0.4.0`, `v0.4.0-alpha`, `v0.4.0-beta`, `v0.4.0-rc1`) |
PyPI uploads were failing with "File already exists" because the version was hardcoded to
0.1.0while git tags likev0.3.0-alphaexisted. CI would always build0.1.0regardless of the tag pushed.Changes
pyproject.toml: Replace hardcoded version withsetuptools-scmfor automatic version derivation from git tagssetuptools-scm>=8.0to build dependenciesdynamic = ["version"]-alpha,-beta,-rcsuffixessrc/meshcore_proxy/__init__.py: Replace static__version__ = "0.1.0"with dynamic import from package metadata.github/workflows/ci.yml: Addfetch-depth: 0to checkout step so setuptools-scm can access git historyREADME.md: Document versioning workflow and release processVersion Resolution
v0.4.0-alpha0.4.0a0v0.4.0-alpha0.4.0a1.dev20.0.0.dev0Each git tag now produces a unique PyPI version matching the tag, preventing upload conflicts.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.