11name : Kazoo Awesome Release
22
33on :
4+ workflow_call :
5+ inputs :
6+ TAG_BUILD :
7+ description : ' The egg info tag build (will be appended to `kazoo.version` value)'
8+ default : " "
9+ required : false
10+ type : string
11+ USE_TEST_PYPI :
12+ description : ' Whether to the use the TestPyPI repository or not'
13+ default : false
14+ required : false
15+ type : boolean
16+ PYTHON_VERSION :
17+ description : ' The Python version to use to perform the steps'
18+ default : " "
19+ required : true
20+ type : string
421 push :
522 tags :
623 - ' *'
724
25+ env :
26+ DEFAULT_TOOLING_PYTHON_VERSION : " 3.10"
27+
828jobs :
929 build-and-release :
10- name : Build and release Kazoo to Pypi
30+ name : Build and release Kazoo to PyPI
1131 runs-on : ubuntu-latest
1232 steps :
33+
34+ # this is to handle the on:push:tags case, to which it is not possible to set
35+ # default values
36+ - name : Maybe set default vars
37+ id : thevars
38+ run : |
39+ DEFINED_PYTHON_VERSION=${{ inputs.PYTHON_VERSION }}
40+ echo "PYTHON_VERSION=${DEFINED_PYTHON_VERSION:-"${{ env.DEFAULT_TOOLING_PYTHON_VERSION }}"}" >> $GITHUB_OUTPUT
41+
1342 - name : Handle the code
1443 uses : actions/checkout@v3
1544
16- - name : Set up Python 3.10
45+ - name : Set up Python
1746 uses : actions/setup-python@v4
1847 with :
19- python-version : " 3.10 "
48+ python-version : ${{ steps.thevars.outputs.PYTHON_VERSION }}
2049
2150 - name : Install pypa/build
2251 run : >-
@@ -29,15 +58,22 @@ jobs:
2958 run : >-
3059 python -m
3160 build
32- -C--global -option=egg_info
33- -C--global -option=--tag-build=""
61+ -C--build -option=egg_info
62+ -C--build -option=--tag-build="${{ inputs.TAG_BUILD }} "
3463 --sdist
3564 --wheel
3665 --outdir dist/
3766 .
3867
68+ - name : Publish Kazoo to TestPyPI
69+ if : ${{ inputs.USE_TEST_PYPI }}
70+ uses : pypa/gh-action-pypi-publish@release/v1
71+ with :
72+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
73+ repository_url : https://test.pypi.org/legacy/
74+
3975 - name : Publish Kazoo to PyPI
40- if : startsWith( github.ref, 'refs/tags')
41- uses : pypa/gh-action-pypi-publish@master
76+ if : ${{ github.event_name == 'push' || !inputs.USE_TEST_PYPI }}
77+ uses : pypa/gh-action-pypi-publish@release/v1
4278 with :
4379 password : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments