Skip to content

Commit 02ccefe

Browse files
committed
Automate release process with workflow_dispatch
Add release.yml workflow that handles the full release: prepare changelog, commit, tag, build, test, publish to PyPI, create GitHub release, and start next development cycle. Move publish jobs out of test.yml (CI only tests now). Update RELEASING.rst with instructions to run the workflow.
1 parent 47d046f commit 02ccefe

File tree

3 files changed

+72
-88
lines changed

3 files changed

+72
-88
lines changed

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version (e.g. 0.6)"
8+
required: true
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
environment: release
14+
permissions:
15+
contents: write
16+
id-token: write
17+
steps:
18+
- uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Configure git
23+
run: |
24+
git config user.name "github-actions[bot]"
25+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
26+
27+
- name: Prepare changelog
28+
run: python make_changelog.py "${{ github.event.inputs.version }}"
29+
30+
- name: Commit and tag
31+
run: |
32+
git commit -am "Prepare release ${{ github.event.inputs.version }}"
33+
git tag "v${{ github.event.inputs.version }}"
34+
git push origin "v${{ github.event.inputs.version }}"
35+
36+
- name: Build
37+
uses: hynek/build-and-inspect-python-package@v2.14
38+
with:
39+
upload-name-suffix: -release
40+
41+
- name: Download Package
42+
uses: actions/download-artifact@v8
43+
with:
44+
name: Packages-release
45+
path: dist
46+
47+
- name: Publish to PyPI
48+
uses: pypa/gh-action-pypi-publish@v1.13.0
49+
with:
50+
attestations: true
51+
52+
- name: Create GitHub Release
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
gh release create "v${{ github.event.inputs.version }}" --generate-notes dist/*
57+
58+
- name: Start next development cycle
59+
run: |
60+
python make_changelog.py UNRELEASED
61+
git commit -am "Start next development cycle"
62+
git push origin main

.github/workflows/test.yml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -79,45 +79,3 @@ jobs:
7979
shell: bash
8080
run: |
8181
tox run -e py --installpkg `find dist/*.tar.gz`
82-
83-
pypi-publish:
84-
if: github.ref_type == 'tag'
85-
needs: [changelog, package, test]
86-
runs-on: ubuntu-latest
87-
environment: release
88-
permissions:
89-
id-token: write
90-
91-
steps:
92-
- name: Download Package
93-
uses: actions/download-artifact@v8
94-
with:
95-
name: Packages
96-
path: dist
97-
98-
- name: Publish to PyPI
99-
uses: pypa/gh-action-pypi-publish@v1.13.0
100-
with:
101-
attestations: true
102-
103-
github-release:
104-
if: github.ref_type == 'tag'
105-
needs: [pypi-publish]
106-
runs-on: ubuntu-latest
107-
permissions:
108-
contents: write
109-
110-
steps:
111-
- uses: actions/checkout@v6
112-
113-
- name: Download Package
114-
uses: actions/download-artifact@v8
115-
with:
116-
name: Packages
117-
path: dist
118-
119-
- name: Create GitHub Release
120-
env:
121-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122-
run: |
123-
gh release create "${{ github.ref_name }}" --generate-notes dist/*

RELEASING.rst

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,23 @@ Versions are derived automatically from git tags.
88
.. _setuptools-scm: https://github.com/pypa/setuptools-scm
99

1010

11-
Version
12-
-------
13-
14-
``main`` should always be green and a potential release candidate.
15-
``unittest2pytest`` follows semantic versioning, so given that the
16-
current version is ``X.Y.Z``, to find the next version number one
17-
needs to look at the ``CHANGELOG.rst`` file:
18-
19-
- If there any new feature, then we must make a new **minor** release:
20-
next release will be ``X.Y+1.0``.
21-
22-
- Otherwise it is just a **bug fix** release: ``X.Y.Z+1``.
23-
24-
2511
Steps
2612
-----
2713

28-
To publish a new release ``X.Y.Z``, the steps are as follows:
29-
30-
#. Update ``CHANGELOG.rst``:
31-
32-
.. code-block:: console
33-
34-
python make_changelog.py X.Y.Z
35-
36-
This replaces the ``UNRELEASED`` section with a dated ``X.Y.Z``
37-
section. Review the result and add any missing entries before
38-
committing.
39-
40-
#. Commit and push:
41-
42-
.. code-block:: console
43-
44-
git commit -am "Prepare release X.Y.Z"
45-
git push origin main
46-
47-
#. Tag and push:
48-
49-
.. code-block:: console
50-
51-
git tag -s vX.Y.Z -m "unittest2pytest X.Y.Z"
52-
git push origin vX.Y.Z
14+
Run the **Release** workflow from the Actions tab:
5315

54-
Pushing the tag triggers the CI workflow, which builds, tests,
55-
publishes to PyPI, and creates a GitHub release.
16+
.. code-block:: console
5617
57-
#. Start the next development cycle:
18+
gh workflow run release.yml -R pytest-dev/unittest2pytest --field version=X.Y.Z
5819
59-
.. code-block:: console
20+
The workflow will:
6021

61-
python make_changelog.py UNRELEASED
62-
git commit -am "Start next development cycle"
63-
git push origin main
22+
#. Run ``make_changelog.py X.Y.Z`` to date the ``UNRELEASED`` section.
23+
#. Commit, tag ``vX.Y.Z``, and push.
24+
#. Run ``make_changelog.py UNRELEASED`` and push a follow-up commit.
25+
#. Build the package and run the full test matrix.
26+
#. Publish to PyPI (requires the ``release`` environment).
27+
#. Create a GitHub Release with the built artifacts.
6428

6529

6630
How versioning works

0 commit comments

Comments
 (0)