Auto publish pip package on git tag and creating github release

Github action to upload PIP package and create Github release

If you created PIP package, for sure you want to know exactly what source code version was published as all the versions you created on

This is not enough to write down git commit. Because you need strong link between code and the moment when you published the version.

One approach - to use git tag and publish the commit with the tag. This way you can be sure what commit was published.

With Github actions you can automate that so each time you create new version tag, Github actions would upload the version.

Result you will have

On ./ bug/feature/release it will

Adaptation for your project

Use aioS3 repo as template.

To work with the project run

. ./

Please note the first . this is how we source the script so it can activate virtual environment. This script will create ethe environment if it does not exists.

It is always safe just rm -r venv if for some reason you want fresh installation, for example to upgrage dependencies. On the next run will recreate it. also install your package in dev mode pip install -e . so what you import would be the lastes version in your source code.

If you use the same requirements.txt as I do you can leave this file intact.

Just do not forget to install virtualenv.

Change aios3 in line from src.aios3 import version with your package name.

Place your package in src/. PIP will auto-discover all packages inside src folder.

Use to create version tags, do not create the tags manually.

The version consists of three digits:


For example to increase last number in version use command

./ bug

To increase 1st

./ release

This script also updates in sources. You can use this Python module to show version from you application.

And this file is used in to set your package version while uploading to

Do not forget to edit VERSION_FILES in (if you have a number of packages inside src you can make create version files in each of them - list them separated by space).

Github action .github/workflows/pip_publish.yml

In line body:$/ change aios3 with your package name.