Skip to content

Fix PyPI release pipeline with dynamic versioning from git tags#6

Merged
rgregg merged 4 commits intomainfrom
copilot/fix-release-pipeline-to-pipy
Jan 17, 2026
Merged

Fix PyPI release pipeline with dynamic versioning from git tags#6
rgregg merged 4 commits intomainfrom
copilot/fix-release-pipeline-to-pipy

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 17, 2026

PyPI uploads were failing with "File already exists" because the version was hardcoded to 0.1.0 while git tags like v0.3.0-alpha existed. CI would always build 0.1.0 regardless of the tag pushed.

Changes

  • pyproject.toml: Replace hardcoded version with setuptools-scm for automatic version derivation from git tags

    • Added setuptools-scm>=8.0 to build dependencies
    • Set dynamic = ["version"]
    • Configured tag regex to handle -alpha, -beta, -rc suffixes
  • src/meshcore_proxy/__init__.py: Replace static __version__ = "0.1.0" with dynamic import from package metadata

  • .github/workflows/ci.yml: Add fetch-depth: 0 to checkout step so setuptools-scm can access git history

  • README.md: Document versioning workflow and release process

Version Resolution

Scenario Example Tag Package Version
On tagged commit v0.4.0-alpha 0.4.0a0
2 commits after tag v0.4.0-alpha 0.4.0a1.dev2
No tags - 0.0.0.dev0

Each git tag now produces a unique PyPI version matching the tag, preventing upload conflicts.

Original prompt

This section details on the original issue you should resolve

<issue_title>Release to PiPy isn't working</issue_title>
<issue_description>There's an issue with the release pipeline shipping to PiPY:

Run python -m twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading meshcore_proxy-0.1.0-py3-none-any.whl
25l
  0% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/26.1 kB • --:-- • ?
  0% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/26.1 kB • --:-- • ?
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 26.1/26.1 kB • 00:00 • 82.8 MB/s
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 26.1/26.1 kB • 00:00 • 82.8 MB/s
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 26.1/26.1 kB • 00:00 • 82.8 MB/s
25hWARNING  Error during upload. Retry with the --verbose option for more details. 
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/        
         File already exists ('meshcore_proxy-0.1.0-py3-none-any.whl', with     
         blake2_256 hash                                                        
         '9db71050bd8a32301af3c3a441f93b72315ee0318ca37e89f2e19c2634feadef').   
         See https://pypi.org/help/#file-name-reuse for more information.       
Error: Process completed with exit code 1.
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix release pipeline for uploading to PiPy Fix PyPI release pipeline with dynamic versioning from git tags Jan 17, 2026
Copilot AI requested a review from rgregg January 17, 2026 03:59
@rgregg rgregg marked this pull request as ready for review January 17, 2026 04:05
Copilot AI review requested due to automatic review settings January 17, 2026 04:05
@rgregg rgregg merged commit b6bf204 into main Jan 17, 2026
11 checks passed
@rgregg rgregg deleted the copilot/fix-release-pipeline-to-pipy branch January 17, 2026 04:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +5 to +9
try:
__version__ = version("meshcore-proxy")
except PackageNotFoundError:
# Package is not installed
__version__ = "0.0.0.dev0"
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.

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`)
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)"

Suggested change
**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`)

Copilot uses AI. Check for mistakes.
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.

Release to PiPy isn't working

3 participants