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=${{ github.event.inputs.PYTHON_VERSION }}
40+ echo "::set-output name=PYTHON_VERSION::${DEFINED_PYTHON_VERSION:-"${{ env.DEFAULT_TOOLING_PYTHON_VERSION }}"}"
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 : >-
@@ -30,14 +59,21 @@ jobs:
3059 python -m
3160 build
3261 -C--global-option=egg_info
33- -C--global-option=--tag-build=""
62+ -C--global-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 == 'true'
70+ uses : pypa/gh-action-pypi-publish@master
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')
76+ if : inputs.USE_TEST_PYPI == 'false'
4177 uses : pypa/gh-action-pypi-publish@master
4278 with :
4379 password : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments