Skip to content

Publish releases to PyPI from GitHub Actions - #663

Merged
tompollard merged 1 commit into
mainfrom
publish-workflow
Nov 23, 2026
Merged

tompollard merged 1 commit into
mainfrom
publish-workflow

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

Add a Publish workflow that builds the package from a published GitHub release and uploads it to PyPI with Trusted Publishing. PyPI then shows provenance for each file: signed attestations (PEP 740) of the repository, commit and workflow that built it. The current releases were uploaded by hand with an API token, so PyPI shows "None of the files in this release were uploaded with provenance metadata."

  • On a published release: the build job checks that the release tag is v followed by the version in pyproject.toml, builds the wheel and source distribution with uv build, and passes them to the publish job. That job runs in the pypi environment with only id-token: write, and uploads them with pypa/gh-action-pypi-publish, which creates and uploads the attestations.
  • On a pull request that changes the workflow, or when run by hand: only the build runs, so nothing is uploaded.

With this, a release is made by creating the GitHub release (tag and notes), and CI uploads it. No PyPI token is needed.

Before the next release

  1. On PyPI, in the project settings under Publishing, add a GitHub publisher: owner MIT-LCP, repository wfdb-python, workflow publish.yml, environment pypi.
  2. In this repository's settings, create an environment named pypi, ideally requiring a maintainer's approval before each upload.

Testing

  • actionlint reports no problems.
  • The tag check accepts v5.1.0 and rejects a different version or a tag without the v.
  • uv build produces a wheel and source distribution that pass twine check. The build job also runs on this pull request.
  • The upload can only be tested by a release, after the setup above.

@tompollard 🟥 red 🦥 sloth · aspen

@tompollard
tompollard merged commit c008f59 into main Nov 23, 2026
20 checks passed
@tompollard
tompollard deleted the publish-workflow branch November 23, 2026 21:54
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.

1 participant