53 Auto version bumping (Python)
When we want to finally publish our package, we still need to manage the metadata in the pyproject.toml file to make sure the version value is up to date.
53.1 Package versioning
Semantic versioning uses the major.minor.patch numbering scheme for package versions
- See these resources about semantic versioning -https://py-pkgs.org/07-releasing-versioning#version-numbering
- https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-versions.html#semver-rules
- https://semver.org/
Calenar versioning (calver) is another way to version package, it uses part of the date of publishing in the package version number
53.2 Auto version bumping
PyOpenSci discusses the pros and cons of different version bumping tools: https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-versions.html#tools-for-bumping-python-package-versions
53.3 python semantic-release
The Python Semantic Release (PSR) package can be used to help automatically bump your package versions: https://python-semantic-release.readthedocs.io/en/latest/
It will auto bump the respective major/minor/patch value based on specific keywords in your commit messages. These commit messages follow the conventional commits pattern https://www.conventionalcommits.org/en/v1.0.0/
Resources:
53.5 Github Actions and PyPI/Test
- Make sure you have a PyPI token in your github actions secrets
- Make sure your package on PyPI / PyPI test is set to accept github as a publisher
- Go to your package page
- Open up the Manage Project setting
- Go to the Publisher setting
- Scroll down to Add a new publisher setting
- Fill in your corresponding Github information (owner, repo name, workflow file name)
If your PyPi package is building and fails on the last step with a Bad Request, this may be the reason why
ERROR HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
Bad Request