From c11a0cf0bd037dd41ab1d436aa7215f33e5d5879 Mon Sep 17 00:00:00 2001 From: Ralph Urlus Date: Thu, 11 Apr 2024 09:57:21 +0200 Subject: [PATCH] CICD: Switch to trusted publisher based auth for releases to PyPi --- .github/workflows/wheels.yml | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e40cc12..c2b7d2c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -104,11 +104,37 @@ jobs: name: artifact-macos-x86-64 path: wheelhouse/*.whl - upload_all: - name: Upload if release + publish-to-testpypi: + name: Publish release on TestPyPi needs: [build_sdist, build_wheels, build_macos_intel] runs-on: ubuntu-latest + environment: testrelease + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - uses: actions/download-artifact@v4 + with: + pattern: artifact-* + merge-multiple: true + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + skip_existing: true + + pypi-publish: + name: Publish release on PyPi + needs: [build_sdist, build_wheels, build_macos_intel, publish-to-testpypi] + runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' + environment: release + permissions: + id-token: write steps: - uses: actions/setup-python@v5 @@ -123,5 +149,4 @@ jobs: - uses: pypa/gh-action-pypi-publish@release/v1 with: - user: ${{ secrets.PYPI_USER }} - password: ${{ secrets.PYPI_PASS }} + skip_existing: true