Skip to content

Commit

Permalink
Add trusted publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Dec 18, 2023
1 parent aa9546e commit 3fa32f8
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.9", "3.10", "3.11"]
install: ["-e .[dev,service,plotting]"]
install: ["-e .[dev]"]
# Make one version be non-editable to test both paths of version code
include:
- os: "ubuntu-latest"
python: "3.8"
install: ".[dev,service,plotting]"
install: ".[dev]"

runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -177,11 +177,9 @@ jobs:

release:
# upload to PyPI and make a release on every tag
needs: [lint, dist, test]
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
needs: [dist]
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
env:
HAS_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN != '' }}

steps:
- uses: actions/download-artifact@v3
Expand All @@ -203,8 +201,17 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pypi:
needs: [dist]
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
# this permission is mandatory for trusted publishing To PyPI
id-token: write
# Specify the GitHub Environment to publish to
environment: release

steps:
- uses: actions/download-artifact@v3
- name: Publish to PyPI
if: ${{ env.HAS_PYPI_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}

0 comments on commit 3fa32f8

Please sign in to comment.