This project publishes to PyPI from GitHub Actions using PyPI Trusted Publishing. The release workflow builds distributions on every manual run and publishes only when a GitHub Release is published.
- Configure a PyPI Trusted Publisher for the existing
densratioproject:- Owner:
hoxo-m - Repository:
densratio_py - Workflow:
release.yml - Environment:
pypi
- Owner:
- Configure the GitHub environment named
pypiin repository settings. Required reviewers are recommended for this environment. - Do not add a long-lived PyPI API token to GitHub secrets. Trusted Publishing uses GitHub OIDC and short-lived PyPI credentials during the release job.
-
Update package metadata and docs:
- Set the next version in
setup.py. - Move release notes from
CHANGELOG.md'sUnreleasedsection into a dated version section. - Update README examples if the public API changed.
- Set the next version in
-
Run local release checks:
python -m pip install -e .[dev] python -m pytest python -m build python -m twine check dist/* -
Open and merge a release-prep PR into
main. -
Confirm the GitHub Actions CI workflow is green on
main. -
Create a GitHub Release:
- Tag:
vX.Y.Z, matching the package versionX.Y.Z. - Target:
main. - Title:
densratio X.Y.Z. - Body: the matching section from
CHANGELOG.md.
- Tag:
-
Publish the GitHub Release. The
Releaseworkflow will build the package and publish it to PyPI after thepypienvironment is approved. The workflow rejects releases whosevX.Y.Ztag does not match the package version. -
Verify the published package:
python -m pip install --upgrade densratio==X.Y.Z python -c "from densratio import densratio, uLSIF, RuLSIF, KLIEP; print('ok')"
Use the workflow_dispatch trigger on the Release workflow to build and
check distributions without publishing to PyPI.