Skip to content

Commit 4a3b828

Browse files
authored
Merge pull request #58 from pytest-dev/release-using-github-actions/1/dev
Release using GitHub actions
2 parents c323e7b + 3212bc2 commit 4a3b828

File tree

3 files changed

+81
-13
lines changed

3 files changed

+81
-13
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish package to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build:
10+
name: Build distribution packages
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python 3.10
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10"
18+
- name: Install pypa/build
19+
run: |
20+
python -m pip install --user build
21+
- name: Build packages
22+
run: |
23+
pyproject-build
24+
- uses: actions/upload-artifact@v3
25+
with:
26+
name: dist
27+
path: dist/
28+
if-no-files-found: error
29+
publish-to-test-pypi:
30+
name: Publish packages to Test PyPI
31+
runs-on: ubuntu-latest
32+
needs: [build]
33+
environment: test-pypi
34+
steps:
35+
- uses: actions/download-artifact@v3
36+
with:
37+
name: dist
38+
path: dist/
39+
- name: Publish packages to Test PyPI
40+
uses: pypa/gh-action-pypi-publish@release/v1
41+
with:
42+
password: '${{ secrets.TEST_PYPI_API_TOKEN }}'
43+
repository_url: https://test.pypi.org/legacy/
44+
print_hash: true
45+
publish-to-pypi:
46+
name: Publish packages to PyPI
47+
runs-on: ubuntu-latest
48+
needs: [build]
49+
environment: pypi
50+
steps:
51+
- uses: actions/download-artifact@v3
52+
with:
53+
name: dist
54+
path: dist/
55+
- name: Publish packages to PyPI
56+
uses: pypa/gh-action-pypi-publish@release/v1
57+
with:
58+
password: '${{ secrets.PYPI_API_TOKEN }}'
59+
print_hash: true

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ repos:
4343
args: [--py3-plus]
4444

4545
- repo: https://github.com/rhysd/actionlint
46-
rev: v1.6.15
46+
rev: v1.6.23
4747
hooks:
4848
- id: actionlint-docker

README.rst

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,26 @@ Preparing a release
218218
For package maintainers, here is how we release a new version:
219219

220220
#. Ensure that the ``CHANGES`` file is up to date with the latest changes.
221-
#. Create a tag whose name is the `PEP 440`_-compliant version number prefixed
222-
by ``v``, making sure to include at least three version number components
223-
(e.g. ``v0.6.0``).
224-
#. Make sure that all tests pass on the tagged version.
225-
#. Push the tag to Github.
226-
#. Make a fresh clone of the repository, and in the root directory of the new
227-
clone, run ``pyproject-build`` (from the `build`_ package). This will create
228-
source and wheel packages under ``dist/``.
229-
#. Upload the source and wheel to PyPI using ``twine upload`` (see `twine`_).
230-
#. Using the `new release form on Github`_, prepare notes for the new release
231-
following the pattern of previous releases. The "Auto-generate release notes"
232-
button will be useful in summarizing the changes since the last release.
221+
#. Make sure that all tests pass on the version you want to release.
222+
#. Use the `new release form on Github`_ (or some other equivalent method) to
223+
create a new release, following the pattern of previous releases.
224+
225+
* Each release has to be based on a tag. You can either create the tag first
226+
(e.g. using ``git tag``) and then make a release from that tag, or you can
227+
have Github create the tag as part of the process of making a release;
228+
either way works.
229+
* The tag name **must** be the `PEP 440`_-compliant version number prefixed
230+
by ``v``, making sure to include at least three version number components
231+
(e.g. ``v0.6.0``).
232+
* The "Auto-generate release notes" button will be useful in summarizing
233+
the changes since the last release.
234+
235+
#. Using either the `release workflows page`_ or the link in the email you
236+
received about a "Deployment review", go to the workflow run created for
237+
the new release and click "Review deployments", then either approve or reject
238+
the two deployments, one to Test PyPI and one to real PyPI. (It should not be
239+
necessary to reject a deployment unless something really weird happens.)
240+
Once the deployment is approved, Github will automatically upload the files.
233241

234242
----
235243

@@ -254,3 +262,4 @@ For package maintainers, here is how we release a new version:
254262
.. _build: https://pypa-build.readthedocs.io/en/latest/
255263
.. _twine: https://twine.readthedocs.io/en/stable/
256264
.. _new release form on Github: https://github.com/pytest-dev/pytest-localserver/releases/new
265+
.. _release workflows page: https://github.com/pytest-dev/pytest-localserver/actions/workflows/release.yml

0 commit comments

Comments
 (0)