Skip to content

Publish to PyPI when a merge to main changes the version - #92

Merged
ShantanuKodgirwar merged 1 commit into
mainfrom
publish-on-version-bump
Aug 3, 2026
Merged

Publish to PyPI when a merge to main changes the version#92
ShantanuKodgirwar merged 1 commit into
mainfrom
publish-on-version-bump

Conversation

@ShantanuKodgirwar

Copy link
Copy Markdown
Contributor

Releasing currently means publishing a GitHub Release by hand, which is easy
to forget and easy to get wrong -- nothing connected the version in
pyproject.toml to what was actually on PyPI.

A merge to main that changes version in pyproject.toml is now the release
trigger. Merges that leave the version alone do nothing, so the workflow only
runs when there is something to release.

Guards, because a PyPI version cannot be replaced once uploaded:

  • The version is compared against HEAD^, so only an actual bump publishes.
  • If a tag v<version> already exists the run skips with a warning, which
    covers re-runs and reverts.
  • The test matrix (3.11-3.13) now gates the release instead of merely running
    alongside it.

After a successful upload the workflow tags the commit and opens a GitHub
Release with the built artifacts attached, so the tag history matches PyPI.
Creating that release with GITHUB_TOKEN does not re-trigger this workflow --
GitHub suppresses that to prevent recursion.

Publishing a GitHub Release by hand still works as before, and still verifies
that the tag matches pyproject.toml.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com

Releasing currently means publishing a GitHub Release by hand, which is easy
to forget and easy to get wrong -- nothing connected the version in
pyproject.toml to what was actually on PyPI.
A merge to main that changes `version` in pyproject.toml is now the release
trigger. Merges that leave the version alone do nothing, so the workflow only
runs when there is something to release.
Guards, because a PyPI version cannot be replaced once uploaded:
- The version is compared against HEAD^, so only an actual bump publishes.
- If a tag `v<version>` already exists the run skips with a warning, which
covers re-runs and reverts.
- The test matrix (3.11-3.13) now gates the release instead of merely running
alongside it.
After a successful upload the workflow tags the commit and opens a GitHub
Release with the built artifacts attached, so the tag history matches PyPI.
Creating that release with GITHUB_TOKEN does not re-trigger this workflow --
GitHub suppresses that to prevent recursion.
Publishing a GitHub Release by hand still works as before, and still verifies
that the tag matches pyproject.toml.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ShantanuKodgirwar
ShantanuKodgirwar merged commit 606195d into mainAug 3, 2026
3 checks passed
@ShantanuKodgirwar
ShantanuKodgirwar deleted the publish-on-version-bump branch August 3, 2026 10:24
Sign up for freeto 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.

1 participant

@ShantanuKodgirwar