From afce3ee8349acfda0b462da45bad26367399fc02 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Tue, 21 Jan 2025 08:49:23 +0000 Subject: [PATCH 1/2] :construction_worker: Create GitHub Action to upload to PyPI on release --- .github/workflows/publish_pypi.yaml | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/publish_pypi.yaml diff --git a/.github/workflows/publish_pypi.yaml b/.github/workflows/publish_pypi.yaml new file mode 100644 index 0000000000..4897922a6b --- /dev/null +++ b/.github/workflows/publish_pypi.yaml @@ -0,0 +1,30 @@ +--- +name: Upload to PyPI + +# Run workflow on pushes to matching branches +on: # yamllint disable-line rule:truthy + workflow_dispatch: + release: + types: [published] + +jobs: + build-and-publish-to-pypi: + name: Build distribution and publish to PyPI + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 + + - name: Install hatch + run: pip install hatch + + - name: Build with hatch + run: hatch build + + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From 38c0d840f4a6e57a19f7db95d9649fd2a87fcd0f Mon Sep 17 00:00:00 2001 From: James Robinson Date: Tue, 21 Jan 2025 09:13:33 +0000 Subject: [PATCH 2/2] :wrench: Add missing permissions --- .github/workflows/publish_pypi.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/publish_pypi.yaml b/.github/workflows/publish_pypi.yaml index 4897922a6b..30cca6e64f 100644 --- a/.github/workflows/publish_pypi.yaml +++ b/.github/workflows/publish_pypi.yaml @@ -11,6 +11,11 @@ jobs: build-and-publish-to-pypi: name: Build distribution and publish to PyPI runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/data-safe-haven/ + permissions: + id-token: write # needed for trusted publishing steps: - name: Check out the repo uses: actions/checkout@v4