Skip to content

Commit bb2bf2e

Browse files
committed
fix: use PyPI API token instead of trusted publishing
- Replace trusted publishing with API token authentication - Use secrets.PYPI_API_TOKEN and secrets.TEST_PYPI_API_TOKEN - Remove id-token: write permission requirement - Use twine upload directly instead of pypa/gh-action-pypi-publish
1 parent a0dc3f0 commit bb2bf2e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

.github/workflows/publish-pyobsql-pypi.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ on:
2020

2121
permissions:
2222
contents: read
23-
id-token: write # Required for PyPI publishing with trusted publishing
2423

2524
jobs:
2625
build:
@@ -93,7 +92,6 @@ jobs:
9392
runs-on: ubuntu-latest
9493
needs: build
9594
permissions:
96-
id-token: write # Required for PyPI trusted publishing
9795
contents: read
9896

9997
steps:
@@ -105,16 +103,21 @@ jobs:
105103

106104
- name: Publish to Test PyPI
107105
if: needs.build.outputs.publish_to_test_pypi == 'true'
108-
uses: pypa/gh-action-pypi-publish@release/v1
109-
with:
110-
repository-url: https://test.pypi.org/legacy/
111-
packages-dir: dist/
106+
env:
107+
TWINE_USERNAME: __token__
108+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
109+
run: |
110+
pip install twine
111+
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
112112
113113
- name: Publish to PyPI
114114
if: needs.build.outputs.publish_to_test_pypi != 'true'
115-
uses: pypa/gh-action-pypi-publish@release/v1
116-
with:
117-
packages-dir: dist/
115+
env:
116+
TWINE_USERNAME: __token__
117+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
118+
run: |
119+
pip install twine
120+
twine upload dist/*
118121
119122
- name: Display published package info
120123
run: |

0 commit comments

Comments
 (0)