gha-python-packaging-test
is a test and demonstration package for our
GitHub Actions-based Python package
release process.
It is actually published to PyPI
and you can actually install it:
pipx install gha-python-packaging-test
gha_python_packaging_test --version
Here's how it works:
-
The
pyproject.toml
file includes setuptools_scm. This means that the version number comes from the git tags. There's no version number anywhere in the source tree (e.g. not inpyproject.toml
nor insetup.cfg
, nor in the Python code itself). This means that you don't need to make a git commit to update the version number before doing a release. All you need to do is add a new git tag, and GitHub does that for you when you create a GitHub release. -
When you want to release a new version of a project you just create a new GitHub release using either GitHub's web UI or GitHub CLI. See Managing releases in a repository in GitHub's docs.
-
This repo contains a
pypi.yml
workflow that runs when a new GitHub release is published and calls a sharedpypi.yml
workflow in ourworkflows
repo (see Reusing workflows in the GitHub Actions docs). The shared workflow builds the Python package and uploads it to PyPI. Projects will be owned by theeng.hypothes.is
user on PyPI. -
In order for this to work the repo needs to have access to an organization-level GitHub secret named
PYPI_TOKEN
. If you're setting up a new repo get someone with admin access to our GitHub organization to add your new repo to the secret's scopes. See Adding secrets for an organization in GitHub's docs.
For more info see How to Publish a Python Package from GitHub Actions.