These are the steps I take when releasing a version of my Python package to PyPI.

First run your checks/cleaning. I have a post about this here. If any fail, start again.

Run tests.

rm -r .tox; tox  # Continue below while this is running

In a new branch:

Once the release is uploaded, there’s no way to change the on PyPI, or the documentation on Readthedocs, without releasing another version. So take care with these in stable releases.

Commit, push and merge into main.

git commit -a
git push origin head

Pull main, tag the commit and push the tag.

git checkout main
git pull
git tag x.x.x
git push --tags

Create the sdist and upload it.

pip install --upgrade pip setuptools twine
python sdist
twine check dist/mypackage-x.x.x.tar.gz
twine upload dist/mypackage-x.x.x.tar.gz

Update coverage badge.

pip install --upgrade pytest-cov coveralls pyyaml
pytest --cov-branch --cov-report term-missing --cov mypackage tests

Build readthedocs if there’s been changes.

Update related blog posts/stack overflow posts.