From 18d9f72ce27323bea5f7b6dc226e4c69a6f2ebd6 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 c951e98..c5f4803 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -157,11 +157,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 @@ -176,5 +202,4 @@ jobs: - uses: pypa/gh-action-pypi-publish@release/v1 with: - user: ${{ secrets.PYPI_USER }} - password: ${{ secrets.PYPI_PASS }} + skip_existing: true