Skip to content

Commit

Permalink
use OIDC for publishing on PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
mammo0 committed Feb 13, 2024
1 parent 5844a79 commit bf5f4d0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions .github/workflows/release_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
if: ${{ github.event_name == 'push' }}
needs: test
runs-on: ubuntu-latest
# needed for publishing on PyPi with OIDC
permissions:
id-token: write
steps:
# checkout the repo
- uses: actions/checkout@v4
Expand All @@ -55,19 +58,13 @@ jobs:
- name: Build package
run: |
poetry build
# on a regular push publish the package to test PyPI repo
- name: Publish test package
env:
PYPI_TEST_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }}
run: |
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi $PYPI_TEST_TOKEN
poetry publish -r test-pypi
# on a regular push (not pull request) publish the package to test PyPI repo
- name: Publish package distributions to TestPyPI
if: github.event_name != 'pull_request'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# on a release push publish the package to the regular PyPI repo
- name: Publish release package
- name: Publish package distributions to PyPI
if: startsWith(github.event.ref, 'refs/tags')
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit bf5f4d0

Please sign in to comment.