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
21+ secrets :
22+ TEST_PYPI_API_TOKEN :
23+ required : false
24+ PYPI_API_TOKEN :
25+ required : false
426 push :
527 tags :
628 - ' *'
729
30+ env :
31+ DEFAULT_TOOLING_PYTHON_VERSION : " 3.10"
32+
833jobs :
934 build-and-release :
10- name : Build and release Kazoo to Pypi
35+ name : Build and release Kazoo to PyPI
1136 runs-on : ubuntu-latest
1237 steps :
38+
39+ # this is to handle the on:push:tags case, to which it is not possible to set
40+ # default values
41+ - name : Maybe set default vars
42+ id : thevars
43+ run : |
44+ DEFINED_PYTHON_VERSION=${{ inputs.PYTHON_VERSION }}
45+ echo "PYTHON_VERSION=${DEFINED_PYTHON_VERSION:-"${{ env.DEFAULT_TOOLING_PYTHON_VERSION }}"}" >> $GITHUB_OUTPUT
46+
1347 - name : Handle the code
1448 uses : actions/checkout@v3
1549
16- - name : Set up Python 3.10
50+ - name : Set up Python
1751 uses : actions/setup-python@v4
1852 with :
19- python-version : " 3.10 "
53+ python-version : ${{ steps.thevars.outputs.PYTHON_VERSION }}
2054
2155 - name : Install pypa/build
2256 run : >-
@@ -29,15 +63,22 @@ jobs:
2963 run : >-
3064 python -m
3165 build
32- -C--global -option=egg_info
33- -C--global -option=--tag-build=""
66+ -C--build -option=egg_info
67+ -C--build -option=--tag-build="${{ inputs.TAG_BUILD }} "
3468 --sdist
3569 --wheel
3670 --outdir dist/
3771 .
3872
73+ - name : Publish Kazoo to TestPyPI
74+ if : ${{ inputs.USE_TEST_PYPI }}
75+ uses : pypa/gh-action-pypi-publish@release/v1
76+ with :
77+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
78+ repository_url : https://test.pypi.org/legacy/
79+
3980 - name : Publish Kazoo to PyPI
40- if : startsWith( github.ref, 'refs/tags')
41- uses : pypa/gh-action-pypi-publish@master
81+ if : ${{ github.event_name == 'push' || !inputs.USE_TEST_PYPI }}
82+ uses : pypa/gh-action-pypi-publish@release/v1
4283 with :
4384 password : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments