File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ name: Publish to PyPI
33on :
44 push :
55 branches : [ "main" ]
6+ workflow_dispatch :
67
78concurrency :
89 group : publish-pypi-${{ github.ref }}
1415 runs-on : ubuntu-latest
1516 permissions :
1617 contents : read
17- id-token : write
1818 steps :
1919 - name : Checkout repository
2020 uses : actions/checkout@v4
@@ -32,10 +32,28 @@ jobs:
3232 - name : Build sdist and wheel
3333 run : python -m build
3434
35+ - name : Validate PyPI token is available
36+ run : |
37+ if [ -z "${{ secrets.PYPI_API_TOKEN }}" ] && [ -z "${{ secrets.TWINE_PASSWORD }}" ]; then
38+ echo "::error::Missing PyPI API token. Set repository secret PYPI_API_TOKEN (preferred) or TWINE_PASSWORD."
39+ exit 1
40+ fi
41+
42+ - name : Resolve token
43+ id : resolve-token
44+ run : |
45+ if [ -n "${{ secrets.PYPI_API_TOKEN }}" ]; then
46+ echo "token=${{ secrets.PYPI_API_TOKEN }}" >> $GITHUB_OUTPUT
47+ elif [ -n "${{ secrets.TWINE_PASSWORD }}" ]; then
48+ echo "token=${{ secrets.TWINE_PASSWORD }}" >> $GITHUB_OUTPUT
49+ else
50+ echo "token=" >> $GITHUB_OUTPUT
51+ fi
52+
3553 - name : Publish to PyPI
3654 uses : pypa/gh-action-pypi-publish@release/v1
3755 with :
38- password : ${{ secrets.PYPI_API_TOKEN }}
56+ password : ${{ steps.resolve-token.outputs.token }}
3957 skip-existing : true
4058
4159
You can’t perform that action at this time.
0 commit comments