Skip to content

Commit 25ef745

Browse files
committed
Apply more suggestions and fix included fragments
1 parent 9fe96b6 commit 25ef745

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
22

33
on: push
44

5+
# Only trigger this for tag changes.
6+
if: startsWith(github.ref, 'refs/tags/')
7+
58
jobs:
69
build:
710
name: Build the source package
@@ -42,7 +45,6 @@ jobs:
4245
name: python-package-distributions
4346
path: dist/
4447
- name: Publish distribution 📦 to PyPI
45-
if: startsWith(github.ref, 'refs/tags')
4648
uses: pypa/gh-action-pypi-publish@release/v1
4749
publish-to-testpypi:
4850
name: Build and publish Python 🐍 distributions 📦 to TestPyPI

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ Let's begin! 🚀
4444
the name of the release workflow file under
4545
the ``.github/`` folder, see :ref:`workflow-definition`.
4646
Finally add the name of the GitHub Actions environment
47-
set up under your repository.
47+
(``pypi``) we're going set up under your repository.
4848
Register the trusted publisher.
4949
3. Now, go to https://test.pypi.org/manage/account/publishing/ and repeat
50-
the second step.
50+
the second step, but now enter ``testpypi`` as the name of the
51+
GitHub Actions environment.
5152
4. Your "pending" publishers are now ready for their first use and will
5253
create your projects automatically once you use them
5354
for the first time.
@@ -76,6 +77,11 @@ should make GitHub run this workflow:
7677
:language: yaml
7778
:end-before: jobs:
7879

80+
This will also assure that the release workflow is only triggered
81+
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.
84+
7985
Checking out the project and building distributions
8086
===================================================
8187

@@ -101,7 +107,7 @@ So add this to the steps list:
101107
.. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml
102108
:language: yaml
103109
:start-after: version: "3.x"
104-
:end-before: build-n-publish-pypi
110+
:end-before: publish-to-pypi
105111

106112
Defining a workflow job environment
107113
===================================
@@ -125,15 +131,12 @@ Finally, add the following steps at the end:
125131

126132
.. literalinclude:: github-actions-ci-cd-sample/publish-to-test-pypi.yml
127133
:language: yaml
128-
:lines: 39-47
134+
:lines: 41-48
129135

130136
This step uses the `pypa/gh-action-pypi-publish`_ GitHub
131137
Action: After the stored distribution package has been
132138
downloaded by the `download-artifact`_ action, it uploads
133-
the contents of the ``dist/`` folder into PyPI unconditionally,
134-
but only if the current commit is tagged. It is recommended you
135-
use the latest release tag; a tool like GitHub's dependabot can keep
136-
these updated regularly.
139+
the contents of the ``dist/`` folder into PyPI unconditionally.
137140

138141
Separate workflow for publishing to TestPyPI
139142
============================================

0 commit comments

Comments
 (0)