Skip to content

Commit 3653382

Browse files
committed
Apply further improvements
1 parent 1851d9f commit 3653382

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

source/guides/github-actions-ci-cd-sample/publish-to-test-pypi.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
1+
name: Publish Python 🐍 distribution packages 📦 to PyPI and TestPyPI
22

33
on: push
44

55
jobs:
66
build:
7-
name: Build the source package
7+
name: Build distribution packages
88
runs-on: ubuntu-latest
99

1010
steps:
@@ -29,7 +29,7 @@ jobs:
2929

3030
publish-to-pypi:
3131
name: >-
32-
Publish Python 🐍 distributions 📦 to PyPI
32+
Publish Python 🐍 distribution packages 📦 to PyPI
3333
and sign them with Sigstore
3434
needs:
3535
- build

source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,25 @@ username/password combination.
3333
Since this guide will demonstrate uploading to both
3434
PyPI and TestPyPI, we'll need two trusted publishers configured.
3535
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+
3848

3949
Let's begin! 🚀
4050

4151
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``),
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

6482
Creating a workflow definition
@@ -79,8 +97,7 @@ should make GitHub run this workflow:
7997

8098
This will also ensure that the release workflow is only triggered
8199
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.
84101

85102
Checking 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

129146
Publishing 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

138156
This step uses the `pypa/gh-action-pypi-publish`_ GitHub
139157
Action: after the stored distribution package has been
140158
downloaded by the `download-artifact`_ action, it uploads
141159
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.
143162

144163
Separate 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

155175
That'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

Comments
 (0)