Skip to content

Commit

Permalink
Use trusted publisher to upload to pypi in Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Dec 31, 2023
1 parent 7e962d5 commit f1fa013
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ jobs:
upload_all:
needs: [build_wheels, build_wheels, make_sdist]
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# Use `environment` instead.
# # upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'push' && github.event.action == 'published'
steps:
Expand All @@ -86,7 +91,11 @@ jobs:

- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# Avoid race condition by using multiple CIs
# Use Trusted Publisher feature:
# https://docs.pypi.org/trusted-publishers/
# so no use of PYPI_API_TOKEN
#password: ${{ secrets.PYPI_API_TOKEN }}
#
# Avoid race condition when using multiple CIs
skip-existing: true
verbose: true

0 comments on commit f1fa013

Please sign in to comment.