@@ -33,13 +33,25 @@ username/password combination.
3333Since this guide will demonstrate uploading to both
3434PyPI and TestPyPI, we'll need two trusted publishers configured.
3535The following steps will lead you through creating the "pending" publishers
36- for your new project. However it is also possible to add `trusted publishing `_
37- to any pre-existing project, if you are its owner.
36+ for your new :term: `PyPI project <Project> `.
37+ However it is also possible to add `trusted publishing `_ to any
38+ pre-existing project, if you are its owner.
39+
40+ .. attention ::
41+
42+ If you followed earlier versions of this guide, you will
43+ have created the secrets ``PYPI_API_TOKEN `` and ``TEST_PYPI_API_TOKEN ``
44+ for direct PyPI and TestPyPI access. These are obsolete now and
45+ you should remove them from your GitHub repository and revoke
46+ them in your PyPI and TestPyPI account settings.
47+
3848
3949Let's begin! 🚀
4050
41511. Go to https://pypi.org/manage/account/publishing/.
42- 2. Fill in the name you wish to publish your new project under,
52+ 2. Fill in the name you wish to publish your new
53+ :term: `PyPI project <Project> ` under
54+ (the ``name `` value in your ``setup.cfg `` or ``pyproject.toml ``),
4355 your GitHub username and repository name and
4456 the name of the release workflow file under
4557 the ``.github/ `` folder, see :ref: `workflow-definition `.
@@ -53,12 +65,18 @@ Let's begin! 🚀
5365 create your projects automatically once you use them
5466 for the first time.
5567
56- .. attention ::
68+ .. note ::
5769
5870 If you don't have a TestPyPI account, you'll need to
5971 create it. It's not the same as a regular PyPI account.
6072
6173
74+ .. hint ::
75+
76+ For security reasons, you should require manual approval
77+ on each run for the ``pypi `` environment.
78+
79+
6280.. _workflow-definition :
6381
6482Creating a workflow definition
@@ -79,8 +97,7 @@ should make GitHub run this workflow:
7997
8098This will also ensure that the release workflow is only triggered
8199if the current commit is tagged. It is recommended you use the
82- latest release tag; a tool like GitHub's dependabot can keep
83- these updated regularly.
100+ latest release tag.
84101
85102Checking out the project and building distributions
86103===================================================
@@ -123,7 +140,7 @@ implement secretless trusted publishing to PyPI.
123140
124141.. literalinclude :: github-actions-ci-cd-sample/publish-to-test-pypi.yml
125142 :language: yaml
126- :start-after: name: python-package-distributions
143+ :start-after: path: dist/
127144 :end-before: steps:
128145
129146Publishing the distribution to PyPI
@@ -133,13 +150,15 @@ Finally, add the following steps at the end:
133150
134151.. literalinclude :: github-actions-ci-cd-sample/publish-to-test-pypi.yml
135152 :language: yaml
136- :lines: 41-48
153+ :start-after: id-token: write
154+ :end-before: publish-to-testpypi:
137155
138156This step uses the `pypa/gh-action-pypi-publish `_ GitHub
139157Action: after the stored distribution package has been
140158downloaded by the `download-artifact `_ action, it uploads
141159the contents of the ``dist/ `` folder into PyPI unconditionally.
142- This job also signs the artifacts with Sigstore right after publishing them to PyPI.
160+ This job also signs the artifacts with the `sigstore/gh-action-sigstore-python `_
161+ GitHub Action publishing them to PyPI.
143162
144163Separate workflow for publishing to TestPyPI
145164============================================
@@ -150,7 +169,8 @@ section:
150169
151170.. literalinclude :: github-actions-ci-cd-sample/publish-to-test-pypi.yml
152171 :language: yaml
153- :start-after: uses: pypa/gh-action-pypi-publish@release/v1
172+ :start-after: ./dist/*.whl
173+
154174
155175That's all, folks!
156176==================
@@ -173,6 +193,8 @@ sure that your release pipeline remains healthy!
173193 https://github.com/actions/download-artifact
174194.. _`upload-artifact` :
175195 https://github.com/actions/upload-artifact
196+ .. _`sigstore/gh-action-sigstore-python` :
197+ https://github.com/marketplace/actions/gh-action-sigstore-python
176198.. _Secrets :
177199 https://docs.github.com/en/actions/reference/encrypted-secrets
178200.. _trusted publishing : https://docs.pypi.org/trusted-publishers/
0 commit comments