Skip to content
Myr

Add Trusted Publishing Release Workflow

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Rather than rely on manual releases from a developer laptop, let's use tag pushes to trigger a workflow to publish artifacts to PyPI. This will leverage trusted publishing and upload attestations as well.

authored by Ian Stapleton Cordasco · committed by Ian Stapleton Cordasco · parent 021dc72 · Browse files · 2 files+90 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+90 added−1 removed

  • other:+90 added−1 removed

2 files+90 added−1 removed

added:.github/workflows/publish.yml+89 added
1name: Publish to PyPI23on:4 push:5 tags:6 - "v*"78permissions:9 contents: read1011jobs:12 build:13 name: "Build dists"14 runs-on: "ubuntu-latest"15 environment:16 name: "publish"17 outputs:18 hashes: ${{ steps.hash.outputs.hashes }}1920 steps:21 - name: Harden the runner (Audit all outbound calls)22 uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.023 with:24 egress-policy: audit2526 - name: "Checkout repository"27 uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"2829 - name: "Setup Python"30 uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065"31 with:32 python-version: "3.x"3334 - name: "Install dependencies"35 run: python -m pip install build==0.8.03637 - name: "Build dists"38 run: |39 SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \40 python -m build4142 - name: "Generate hashes"43 id: hash44 run: |45 cd dist && echo "::set-output name=hashes::$(sha256sum * | base64 -w0)"4647 - name: "Upload dists"48 uses: "actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02"49 with:50 name: "dist"51 path: "dist/"52 if-no-files-found: error53 retention-days: 55455 provenance:56 needs: [build]57 permissions:58 actions: read59 contents: write60 id-token: write # Needed to access the workflow's OIDC identity.61 uses: "slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0"62 with:63 base64-subjects: "${{ needs.build.outputs.hashes }}"64 upload-assets: true65 compile-generator: true # Workaround for https://github.com/slsa-framework/slsa-github-generator/issues/11636667 publish:68 name: "Publish"69 if: startsWith(github.ref, 'refs/tags/')70 needs: ["build", "provenance"]71 permissions:72 contents: write73 id-token: write74 runs-on: "ubuntu-latest"7576 steps:77 - name: Harden the runner (Audit all outbound calls)78 uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.079 with:80 egress-policy: audit8182 - name: "Download dists"83 uses: "actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093"84 with:85 name: "dist"86 path: "dist/"8788 - name: "Publish dists to PyPI"89 uses: "pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc"
modified:Makefile+1 added-1 removed
20 unmodified lines
21 .publishenv/bin/pip install 'twine>=1.5.0' build2223publish: .publishenv24 .publishenv/bin/python -m build25 .publishenv/bin/python twine upload --skip-existing dist/*25 .publishenv/bin/python -m twine upload --skip-existing dist/*26 rm -fr build dist .egg requests.egg-info2728docs:29 cd docs && make html
1 unmodified line