Skip to content

Commit

Permalink
build: Update deployment action with trusted publisher (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
havogt authored Jan 31, 2024
1 parent f34ab13 commit 98d353f
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/python-package-tests-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:

jobs:
build-wheel:
build:
runs-on: ubuntu-latest
container: ghcr.io/gridtools/gridtools-base:${{ matrix.compiler }}
strategy:
Expand Down Expand Up @@ -39,22 +39,40 @@ jobs:
with:
name: gridtools-cpp-wheel
path: .python_package/.nox/.cache/dist/gridtools_cpp-*.whl
- name: Publish distribution to Test PyPI
if: ${{ github.event_name == 'release' }}
publish-pypi:
name: Publish Python distribution to pypi.org
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'workflow_dispatch' }} # the action was triggered manually
environment:
name: pypi
url: https://pypi.org/project/gridtools-cpp
permissions:
id-token: write
steps:
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages-dir: .python_package/.nox/.cache/dist
packages-dir: .python_package/.nox/.cache/dist
publish-test-pypi:
name: Publish Python distribution to test.pypi.org
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'release' }} # triggered by releasing on github, test first before manually triggering the deployment to PyPI (see release documentation)
environment:
name: testpypi
url: https://test.pypi.org/project/gridtools-cpp
permissions:
id-token: write
steps:
- name: Publish distribution to PyPI
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: .python_package/.nox/.cache/dist
packages-dir: .python_package/.nox/.cache/dist
repository_url: https://test.pypi.org/legacy/

test-wheel:
needs: build-wheel
needs: build
runs-on: ubuntu-latest
container: ghcr.io/gridtools/gridtools-base:${{ matrix.compiler }}
strategy:
Expand Down

0 comments on commit 98d353f

Please sign in to comment.