Skip to content

Commit 3027463

Browse files
committed
Switch to Trusted Publishing for publishing packages to PyPI
1 parent abef267 commit 3027463

7 files changed

Lines changed: 82 additions & 18 deletions

File tree

.github/workflows/tests.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,64 @@ jobs:
6666
uvx coveralls --service=github
6767
env:
6868
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Build package artifacts
71+
if: >
72+
matrix.os[0] == 'ubuntu'
73+
&& matrix.config[1] == 'py314'
74+
run: |
75+
rm -f dist/*
76+
pip install -U packaging "setuptools >= 78.1.1,< 82" wheel twine
77+
python setup.py sdist
78+
python setup.py bdist_wheel
79+
80+
- name: Upload package wheel
81+
if: >
82+
matrix.os[0] == 'ubuntu'
83+
&& matrix.config[1] == 'py314'
84+
uses: actions/upload-artifact@v7
85+
with:
86+
name: Zope.whl
87+
path: dist/*whl
88+
89+
- name: Upload package source distribution
90+
if: >
91+
matrix.os[0] == 'ubuntu'
92+
&& matrix.config[1] == 'py314'
93+
uses: actions/upload-artifact@v7
94+
with:
95+
name: Zope.tar.gz
96+
path: dist/*gz
97+
98+
publish:
99+
name: Publish to PyPI
100+
runs-on: ubuntu-latest
101+
# Only publish on tag pushes
102+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
103+
# Wait for build jobs to complete
104+
needs: [build]
105+
environment:
106+
name: pypi
107+
url: https://pypi.org/p/Zope
108+
permissions:
109+
contents: read
110+
id-token: write # Mandatory for trusted publishing
111+
112+
steps:
113+
- name: Download package artifacts
114+
uses: actions/download-artifact@v8
115+
with:
116+
path: dist/
117+
pattern: '*'
118+
merge-multiple: true
119+
120+
- name: Display structure of downloaded files
121+
run: |
122+
ls -lR dist/
123+
124+
- name: Publish to PyPI
125+
uses: pypa/gh-action-pypi-publish@release/v1
126+
with:
127+
skip-existing: true
128+
packages-dir: dist/
129+
verbose: true

.meta.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://github.com/zopefoundation/meta/tree/master/src/zope/meta/zope-product
33
[meta]
44
template = "zope-product"
5-
commit-id = "ba10c93f"
5+
commit-id = "4a693eeb"
66

77
[python]
88
with-pypy = false
@@ -112,3 +112,6 @@ ignore = [
112112

113113
[pre-commit]
114114
teyit-exclude = "App/tests/fixtures/error\\.py"
115+
116+
[pypi]
117+
trusted-publishing = true

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ https://github.com/zopefoundation/Zope/blob/5.x/CHANGES.rst.
1414

1515
- Update to newest compatible versions of dependencies.
1616

17+
- Switch to Trusted Publishing for publishing packages to PyPI.
18+
1719

1820
6.1 (2026-04-22)
1921
----------------

docs/maintenance.rst

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,11 @@ Steps for creating a new Zope release
6060

6161
- If the tests succeed, commit the changes.
6262

63-
- Clear out documentation build artifacts to prevent adding these files to
64-
the package::
65-
66-
$ rm -rf docs/_build
67-
68-
- Upload the tagged release to PyPI::
69-
70-
$ bin/release # if you use zest.releaser
71-
72-
or
63+
- Create and push the release tag. This will trigger the publishing workflow on
64+
GitHub::
7365

7466
$ git tag -as <TAG-NAME> -m "- tagging release <TAG-NAME>"
7567
$ git push --tags
76-
$ bin/buildout setup setup.py sdist bdist_wheel
77-
$ bin/twine upload dist/Zope-<TAG-NAME>*
7868

7969
- Update version information in the change log and ``pyproject.toml``::
8070

@@ -91,7 +81,12 @@ Steps for creating a new Zope release
9181

9282
- Commit and push the changes.
9383

94-
- Check that the changes have been propagated to https://zope.readthedocs.io/en/latest/changes.html.
84+
- Check that the package publishing workflow has succeeded at
85+
https://github.com/zopefoundation/Zope/actions and
86+
https://pypi.org/project/Zope/#history
87+
88+
- Check that the changes have been propagated to
89+
https://zope.readthedocs.io/en/latest/changes.html.
9590
(This should be done automatically via web hooks defined in GitHub and RTD.)
9691

9792
- Update https://zopefoundation.github.io/Zope/::

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://github.com/zopefoundation/meta/tree/master/src/zope/meta/zope-product
33
[build-system]
44
requires = [
5-
"setuptools >= 78.1.1,< 81",
5+
"setuptools >= 78.1.1,< 82",
66
"wheel",
77
]
88
build-backend = "setuptools.build_meta"
@@ -155,3 +155,7 @@ directory = "parts/htmlcov"
155155

156156
[tool.setuptools.dynamic]
157157
readme = {file = ["README.rst", "CHANGES.rst"]}
158+
159+
[tool.zest-releaser]
160+
create-wheel = false
161+
upload-pypi = false

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Generated with zope.meta (https://zopemeta.readthedocs.io/) from:
22
# https://github.com/zopefoundation/meta/tree/master/src/zope/meta/zope-product
3-
43
[flake8]
54
doctests = 1
65
no-accept-encodings = True

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ envlist =
1616
[testenv]
1717
skip_install = true
1818
deps =
19-
setuptools >= 78.1.1,< 81
19+
setuptools >= 78.1.1,< 82
2020
zc.buildout
2121
wheel
2222
setenv =
@@ -39,7 +39,7 @@ description = ensure that the distribution is ready to release
3939
basepython = python3
4040
skip_install = true
4141
deps =
42-
setuptools >= 78.1.1,< 81
42+
setuptools >= 78.1.1,< 82
4343
wheel
4444
twine
4545
build

0 commit comments

Comments
 (0)