Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trusted publishing (OIDC) #1135

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ jobs:
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
permissions:
# write id-token and attestations are required to attest build provenance
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
persist-credentials: false

- name: Build SDist
run: pipx run build --sdist

- name: Attest GitHub build provenance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over at the pymc repo you had unified the sdist and bdist_wheel steps into a single check from a different tool. Why not do that here too?

Copy link
Contributor Author

@maresb maresb Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compilation/extensions.

From the build-and-inspect-python-package readme:
image

uses: actions/attest-build-provenance@v1
with:
subject-path: dist/*.tar.gz

- uses: actions/upload-artifact@v4
with:
name: sdist
Expand All @@ -45,11 +55,16 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: hynek/build-and-inspect-python-package@v2

build_wheels:
name: Build wheels for ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
permissions:
# write id-token and attestations are required to attest build provenance
id-token: write
attestations: write
strategy:
matrix:
platform:
Expand All @@ -60,10 +75,16 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Build wheels
uses: pypa/[email protected]

- name: Attest GitHub build provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: ./wheelhouse/*.whl

- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform }}
Expand All @@ -72,10 +93,15 @@ jobs:
build_universal_wheel:
name: Build universal wheel for Pyodide
runs-on: ubuntu-latest
permissions:
# write id-token and attestations are required to attest build provenance
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -89,6 +115,11 @@ jobs:
run: |
PYODIDE=1 python setup.py bdist_wheel --universal

- name: Attest GitHub build provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: dist/*.whl

- uses: actions/upload-artifact@v4
with:
name: universal_wheel
Expand Down Expand Up @@ -125,9 +156,16 @@ jobs:

upload_pypi:
name: Upload to PyPI on release
# Use the `release` GitHub environment to protect the Trusted Publishing (OIDC)
# workflow by requiring signoff from a maintainer.
environment: release
permissions:
# write id-token is required for trusted publishing (OIDC)
id-token: write
needs: [check_dist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
# Don't publish from forks
if: github.repository_owner == 'pymc-devs' && github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
Expand All @@ -146,6 +184,4 @@ jobs:
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}
# Implicitly attests that the packages were uploaded in the context of this workflow.
Loading