Skip to content

Plugin: publisher-pypi

Builds Python source and wheel distributions with python -m build and uploads dist/* artifacts to PyPI (or TestPyPI / private indexes) using twine upload.

Terminal window
semrel plugin install @semrel/publisher-pypi

semrel plugin install downloads the binary to .semrel/plugins/ and updates .semrel.lock. Commit .semrel.lock to pin the version for your team.

Pre-built, signed multi-platform images (linux/amd64, linux/arm64) are published on every release:

Terminal window
docker pull ghcr.io/semrels/publisher-pypi:latest

Verify the image signature with cosign:

Terminal window
cosign verify ghcr.io/semrels/publisher-pypi:latest \
--certificate-identity-regexp 'https://github.com/SemRels/publisher-pypi/.github/workflows/release.yml.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
version: 1
plugins:
- uses: @semrel/updater-python
phase: pre-tag
args:
file: pyproject.toml
- uses: @semrel/publisher-pypi
phase: release
args:
pypi_token: '${env.PYPI_API_TOKEN}'
# Optional: target TestPyPI or a private index
# pypi_repository_url: "https://test.pypi.org/legacy/"
NameRequiredDefaultDescription
SEMREL_PLUGIN_PYPI_TOKENyes (unless dry-run)—PyPI API token passed as TWINE_PASSWORD (__token__ username).
SEMREL_PLUGIN_PYPI_REPOSITORY_URLnoPyPI defaultCustom repository URL passed to twine upload --repository-url (e.g. https://test.pypi.org/legacy/).
SEMREL_PLUGIN_WORKDIRno.Project directory where python -m build and dist/ are evaluated.
SEMREL_PLUGIN_PYTHON_BINnopython / python3Override the Python executable name or path.
SEMREL_PLUGIN_TWINE_BINnotwineOverride the twine executable name or path.
  • SEMREL_VERSION
  • SEMREL_NEXT_VERSION
  • SEMREL_DRY_RUN
  1. Detects python or python3 on $PATH.
  2. Runs python -m build in the configured working directory.
  3. Collects artifacts in dist/*.
  4. Uploads distributions via twine upload (or logs the planned artifacts without uploading when SEMREL_DRY_RUN=true).