@@ -33,13 +33,25 @@ username/password combination.
33
33
Since this guide will demonstrate uploading to both
34
34
PyPI and TestPyPI, we'll need two trusted publishers configured.
35
35
The 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
+
38
48
39
49
Let's begin! 🚀
40
50
41
51
1. 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 ``),
43
55
your GitHub username and repository name and
44
56
the name of the release workflow file under
45
57
the ``.github/ `` folder, see :ref: `workflow-definition `.
@@ -53,12 +65,18 @@ Let's begin! 🚀
53
65
create your projects automatically once you use them
54
66
for the first time.
55
67
56
- .. attention ::
68
+ .. note ::
57
69
58
70
If you don't have a TestPyPI account, you'll need to
59
71
create it. It's not the same as a regular PyPI account.
60
72
61
73
74
+ .. hint ::
75
+
76
+ For security reasons, you should require manual approval
77
+ on each run for the ``pypi `` environment.
78
+
79
+
62
80
.. _workflow-definition :
63
81
64
82
Creating a workflow definition
@@ -79,8 +97,7 @@ should make GitHub run this workflow:
79
97
80
98
This will also ensure that the release workflow is only triggered
81
99
if 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.
84
101
85
102
Checking out the project and building distributions
86
103
===================================================
@@ -123,7 +140,7 @@ implement secretless trusted publishing to PyPI.
123
140
124
141
.. literalinclude :: github-actions-ci-cd-sample/publish-to-test-pypi.yml
125
142
:language: yaml
126
- :start-after: name: python-package-distributions
143
+ :start-after: path: dist/
127
144
:end-before: steps:
128
145
129
146
Publishing the distribution to PyPI
@@ -133,13 +150,15 @@ Finally, add the following steps at the end:
133
150
134
151
.. literalinclude :: github-actions-ci-cd-sample/publish-to-test-pypi.yml
135
152
:language: yaml
136
- :lines: 41-48
153
+ :start-after: id-token: write
154
+ :end-before: publish-to-testpypi:
137
155
138
156
This step uses the `pypa/gh-action-pypi-publish `_ GitHub
139
157
Action: after the stored distribution package has been
140
158
downloaded by the `download-artifact `_ action, it uploads
141
159
the 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.
143
162
144
163
Separate workflow for publishing to TestPyPI
145
164
============================================
@@ -150,7 +169,8 @@ section:
150
169
151
170
.. literalinclude :: github-actions-ci-cd-sample/publish-to-test-pypi.yml
152
171
:language: yaml
153
- :start-after: uses: pypa/gh-action-pypi-publish@release/v1
172
+ :start-after: ./dist/*.whl
173
+
154
174
155
175
That's all, folks!
156
176
==================
@@ -173,6 +193,8 @@ sure that your release pipeline remains healthy!
173
193
https://github.com/actions/download-artifact
174
194
.. _`upload-artifact` :
175
195
https://github.com/actions/upload-artifact
196
+ .. _`sigstore/gh-action-sigstore-python` :
197
+ https://github.com/marketplace/actions/gh-action-sigstore-python
176
198
.. _Secrets :
177
199
https://docs.github.com/en/actions/reference/encrypted-secrets
178
200
.. _trusted publishing : https://docs.pypi.org/trusted-publishers/
0 commit comments