@@ -12,7 +12,8 @@ This guide shows you how to publish a Python distribution
1212whenever a tagged commit is pushed.
1313It will use the `pypa/gh-action-pypi-publish GitHub Action `_ for
1414publishing. It also uses GitHub's `upload-artifact `_ and `download-artifact `_ actions
15- for temporarily storing and downloading the source packages.
15+ for temporarily storing and downloading the source packages, and `actions/attest-build-provenance `_
16+ to generate `GitHub artifact attestations `_ for the built distributions.
1617
1718.. attention ::
1819
@@ -101,8 +102,9 @@ Checking out the project and building distributions
101102===================================================
102103
103104We will have to define two jobs to publish to PyPI
104- and TestPyPI respectively, and an additional job to
105- build the distribution packages.
105+ and TestPyPI respectively, an additional job to
106+ build the distribution packages, and a job to generate
107+ GitHub artifact attestations for those packages.
106108
107109First, we'll define the job for building the dist packages of
108110your project and storing them for later use:
@@ -129,6 +131,19 @@ So add this to the steps list:
129131.. literalinclude :: github-actions-ci-cd-sample/publish-to-pypi.yml
130132 :language: yaml
131133 :start-at: Install pypa/build
134+ :end-before: attest-distributions
135+
136+ Generating GitHub artifact attestations
137+ =======================================
138+
139+ After building the distributions, generate a build provenance attestation
140+ for each file in the ``dist/ `` folder. This is separate from uploading
141+ the files to a package index, so the attestation job downloads the stored
142+ artifact and runs before the publishing jobs.
143+
144+ .. literalinclude :: github-actions-ci-cd-sample/publish-to-pypi.yml
145+ :language: yaml
146+ :start-at: attest-distributions
132147 :end-before: publish-to-pypi
133148
134149Defining a workflow job environment
@@ -171,8 +186,9 @@ the contents of the ``dist/`` folder into PyPI unconditionally.
171186 Starting with version
172187 `v1.11.0 <https://github.com/pypa/gh-action-pypi-publish/releases/tag/v1.11.0 >`_,
173188 `pypa/gh-action-pypi-publish `_ generates and uploads :pep: `740 `-compatible
174- attestations for each distribution by default. No additional manual
175- signing steps are required.
189+ attestations for each distribution by default. This complements the GitHub
190+ artifact attestation job above, which records build provenance in GitHub.
191+ No additional manual signing steps are required.
176192
177193
178194Separate workflow for publishing to TestPyPI
@@ -235,6 +251,10 @@ sure that your release pipeline remains healthy!
235251 https://github.com/actions/download-artifact
236252.. _`upload-artifact` :
237253 https://github.com/actions/upload-artifact
254+ .. _`actions/attest-build-provenance` :
255+ https://github.com/actions/attest-build-provenance
256+ .. _`GitHub artifact attestations` :
257+ https://docs.github.com/en/actions/how-tos/secure-your-work/use-artifact-attestations/use-artifact-attestations
238258.. _Secrets :
239259 https://docs.github.com/en/actions/reference/encrypted-secrets
240260.. _Trusted Publishing : https://docs.pypi.org/trusted-publishers/
0 commit comments