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 pypi.org.

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 ./verup.sh bug/feature/release it will

Adaptation for your project

Use aioS3 repo as template.

activate.sh

To work with the project run

. ./activate.sh

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 activate.sh will recreate it.

activate.sh 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.

setup.py

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.

verup.sh

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

The version consists of three digits:

release.feature.bug

For example to increase last number in version use command

./verup.sh bug

To increase 1st

./verup.sh release

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

And this file is used in setup.py to set your package version while uploading to pypi.org.

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

Github action .github/workflows/pip_publish.yml

In line body: https://pypi.org/project/aios3/$/ change aios3 with your package name.