Update publish workflow and add test pypi option
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Nate Prewitt · committed by Nate Prewitt · parent 5f33844 · Browse files · 1 file·+43 added−26 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+43 added−26 removed
- other:+43 added−26 removed
Provenance
- Commit
00600b3- Tree
08a3265- Author
Nate Prewitt <nate.prewitt@gmail.com>- Committer
Nate Prewitt <nate.prewitt@gmail.com>- Parent
5f33844
1 file changed+43 added−26 removed
modified:.github/workflows/publish.yml+43 added-26 removed
2 unmodified lines3456789101112131415161718192015162118222324252627282930283132333435333637383940384142434445464745464748494849505152535455565960616263646566676869705758597460617662636465666768696 unmodified lines767778799380818283848586878889909192939495969798991001011021031041051061071081091102 unmodified lineson: push: tags: - "v*" workflow_dispatch: inputs: test-pypi-only: description: "Publish to Test PyPI only" type: boolean default: true
permissions: contents: read
jobs: build: name: "Build dists" runs-on: "ubuntu-latest" environment: name: "publish" outputs: hashes: ${{ steps.hash.outputs.hashes }} artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 with: egress-policy: audit
- name: "Checkout repository" uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2 with: persist-credentials: false
- name: "Setup Python" uses: "actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405" uses: "actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405" # v6.2.0 with: python-version: "3.x"
- name: "Install dependencies" run: python -m pip install build==0.8.0 run: python -m pip install build==1.4.0
- name: "Build dists" run: | SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \ python -m build
- name: "Generate hashes" id: hash run: | cd dist && echo "::set-output name=hashes::$(sha256sum * | base64 -w0)"
- name: "Upload dists" uses: "actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f" id: upload-artifact with: name: "dist" path: "dist/" if-no-files-found: error retention-days: 5
provenance: needs: [build] permissions: actions: read contents: write id-token: write # Needed to access the workflow's OIDC identity. uses: "slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0" with: base64-subjects: "${{ needs.build.outputs.hashes }}" upload-assets: true compile-generator: true # Workaround for https://github.com/slsa-framework/slsa-github-generator/issues/1163
publish: name: "Publish" if: startsWith(github.ref, 'refs/tags/') needs: ["build", "provenance"] needs: ["build"] permissions: contents: write id-token: write runs-on: "ubuntu-latest" environment: name: "publish"
steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.26 unmodified lines artifact-ids: ${{ needs.build.outputs.artifact-id }} path: "dist/"
- name: "Publish dists to PyPI" uses: "pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e" uses: "pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e" # v1.13.0 with: attestations: true
publish-test-pypi: name: "Publish to Test PyPI" if: github.event_name == 'workflow_dispatch' needs: ["build"] permissions: id-token: write runs-on: "ubuntu-latest" environment: name: "testpypi"
steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 with: egress-policy: audit
- name: "Download dists" uses: "actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131" # v7.0.0 with: artifact-ids: ${{ needs.build.outputs.artifact-id }} path: "dist/"
- name: "Publish dists to Test PyPI" uses: "pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e" # v1.13.0 with: repository-url: https://test.pypi.org/legacy/ attestations: true