@@ -2,8 +2,16 @@ name: Publish to PyPI
22
33on :
44 release :
5- types : [ published ]
5+ types : [published]
66 workflow_dispatch :
7+ inputs :
8+ pypi_target :
9+ description : ' PyPI target (pypi or testpypi)'
10+ default : ' pypi'
11+ type : choice
12+ options :
13+ - pypi
14+ - testpypi
715
816jobs :
917 publish :
@@ -13,23 +21,30 @@ jobs:
1321 id-token : write
1422
1523 steps :
16- - uses : actions/checkout@v4
24+ - uses : actions/checkout@v6
1725
18- - name : Set up Python
19- uses : actions/setup-python@v5
20- with :
21- python-version : ' 3.12'
26+ - name : Set up Python 3.11
27+ uses : actions/setup-python@v6
28+ with :
29+ python-version : " 3.12"
2230
23- - name : Install dependencies
24- run : |
25- python -m pip install --upgrade pip
26- pip install build twine
31+ - name : Install dependencies
32+ run : |
33+ python -m pip install --upgrade pip
34+ pip install build twine
2735
28- - name : Build package
29- run : python -m build
36+ - name : Build package
37+ run : python -m build
3038
31- - name : Check package
32- run : twine check dist/*
39+ - name : Check package
40+ run : twine check dist/*
3341
34- - name : Publish to PyPI
35- uses : pypa/gh-action-pypi-publish@release/v1
42+ - name : Publish to TestPyPI
43+ if : ${{ inputs.pypi_target == 'testpypi' }}
44+ uses : pypa/gh-action-pypi-publish@release/v1
45+ with :
46+ repository-url : https://test.pypi.org/legacy/
47+
48+ - name : Publish to PyPI
49+ if : ${{ inputs.pypi_target == 'pypi' || github.event_name == 'release' }}
50+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments