Debian Codegraph @

RELEASING.rst

raw
1 Release Procedure
2 -----------------
3
4 Our current policy for releasing is to aim for a bug-fix release every few weeks and a minor release every 2-3 months. The idea
5 is to get fixes and new features out instead of trying to cram a ton of features into a release and by consequence
6 taking a lot of time to make a new one.
7
8 The git commands assume the following remotes are setup:
9
10 * ``origin``: your own fork of the repository.
11 * ``upstream``: the ``pytest-dev/pytest`` official repository.
12
13 Preparing: Automatic Method
14 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
16 We have developed an automated workflow for releases, that uses GitHub workflows and is triggered
17 by `manually running <https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow>`__
18 the `prepare-release-pr workflow <https://github.com/pytest-dev/pytest/actions/workflows/prepare-release-pr.yml>`__
19 on GitHub Actions.
20
21 The automation will decide the new version number based on the following criteria:
22
23 - If the "major release" input is set to "yes", release a new major release
24 (e.g. 7.0.0 -> 8.0.0)
25 - If there are any ``.feature.rst`` or ``.breaking.rst`` files in the
26 ``changelog`` directory, release a new minor release (e.g. 7.0.0 -> 7.1.0)
27 - Otherwise, release a bugfix release (e.g. 7.0.0 -> 7.0.1)
28 - If the "prerelease" input is set, append the string to the version number
29 (e.g. 7.0.0 -> 8.0.0rc1), if "major" is set, and "prerelease" is set to `rc1`)
30
31 Bug-fix and minor releases
32 ^^^^^^^^^^^^^^^^^^^^^^^^^^
33
34 Bug-fix and minor releases are always done from a maintenance branch. First,
35 consider double-checking the ``changelog`` directory to see if there are any
36 breaking changes or new features.
37
38 For a new minor release, first create a new maintenance branch from ``main``::
39
40 git fetch upstream
41 git branch 7.1.x upstream/main
42 git push upstream 7.1.x
43
44 Then, trigger the workflow with the following inputs:
45
46 - branch: **7.1.x**
47 - major release: **no**
48 - prerelease: empty
49
50 Or via the commandline using `GitHub's cli <https://github.com/cli/cli>`__::
51
52 gh workflow run prepare-release-pr.yml -f branch=7.1.x -f major=no -f prerelease=
53
54 Where ``7.1.x`` is the maintenance branch for the ``7.1`` series. The automated
55 workflow will publish a PR for a branch ``release-7.1.0``.
56
57 Similarly, for a bug-fix release, use the existing maintenance branch and
58 trigger the workflow with e.g. ``branch: 7.0.x`` to get a new ``release-7.0.1``
59 PR.
60
61 Major releases
62 ^^^^^^^^^^^^^^
63
64 1. Create a new maintenance branch from ``main``::
65
66 git fetch upstream
67 git branch 8.0.x upstream/main
68 git push upstream 8.0.x
69
70 2. Trigger the workflow with the following inputs:
71
72 - branch: **8.0.x**
73 - major release: **yes**
74 - prerelease: empty
75
76 Or via the commandline::
77
78 gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=
79
80 The automated workflow will publish a PR for a branch ``release-8.0.0``.
81
82 At this point on, this follows the same workflow as other maintenance branches: bug-fixes are merged
83 into ``main`` and ported back to the maintenance branch, even for release candidates.
84
85 Release candidates
86 ^^^^^^^^^^^^^^^^^^
87
88 To release a release candidate, set the "prerelease" input to the version number
89 suffix to use. To release a ``8.0.0rc1``, proceed like under "major releases", but set:
90
91 - branch: 8.0.x
92 - major release: yes
93 - prerelease: **rc1**
94
95 Or via the commandline::
96
97 gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=rc1
98
99 The automated workflow will publish a PR for a branch ``release-8.0.0rc1``.
100
101 **A note about release candidates**
102
103 During release candidates we can merge small improvements into
104 the maintenance branch before releasing the final major version, however we must take care
105 to avoid introducing big changes at this stage.
106
107 Preparing: Manual Method
108 ~~~~~~~~~~~~~~~~~~~~~~~~
109
110 **Important**: pytest releases must be prepared on **Linux** because the docs and examples expect
111 to be executed on that platform.
112
113 To release a version ``MAJOR.MINOR.PATCH``, follow these steps:
114
115 #. For major and minor releases, create a new branch ``MAJOR.MINOR.x`` from
116 ``upstream/main`` and push it to ``upstream``.
117
118 #. Create a branch ``release-MAJOR.MINOR.PATCH`` from the ``MAJOR.MINOR.x`` branch.
119
120 Ensure your local checkout is up to date and in a clean working tree.
121
122 #. Using ``tox``, generate docs, changelog, announcements::
123
124 $ tox -e release -- MAJOR.MINOR.PATCH
125
126 This will generate a commit with all the changes ready for pushing.
127
128 #. Open a PR for the ``release-MAJOR.MINOR.PATCH`` branch targeting ``MAJOR.MINOR.x``.
129
130
131 Releasing
132 ~~~~~~~~~
133
134 Both automatic and manual processes described above follow the same steps from this point onward.
135
136 #. After all tests pass and the PR has been approved, trigger the ``deploy`` workflow
137 in https://github.com/pytest-dev/pytest/actions/workflows/deploy.yml, using the ``release-MAJOR.MINOR.PATCH`` branch
138 as source.
139
140 Using the command-line::
141
142 $ gh workflow run deploy.yml -R pytest-dev/pytest --ref=release-{VERSION} -f version={VERSION}
143
144 This job will require approval from ``pytest-dev/core``, after which it will publish to PyPI
145 and tag the repository.
146
147 #. Merge the PR. **Make sure it's not squash-merged**, so that the tagged commit ends up in the main branch.
148
149 #. For major and minor releases (or the first prerelease of it),
150 in the `ReadTheDocs admin page <https://app.readthedocs.org/projects/pytest/>`__, click "Add Version" on the top right,
151 choose the new branch, then set the new version as active.
152
153 #. Cherry-pick the CHANGELOG / announce files to the ``main`` branch::
154
155 git fetch upstream
156 git checkout upstream/main -b cherry-pick-release
157 git cherry-pick -x -m1 upstream/MAJOR.MINOR.x
158
159 #. Open a PR for ``cherry-pick-release`` and merge it once CI passes. No need to wait for approvals if there were no conflicts on the previous step.
160
161 #. For major and minor releases (or the first prerelease of it), tag the release cherry-pick merge commit in main with
162 a dev tag for the next feature release::
163
164 git checkout main
165 git pull
166 git tag MAJOR.{MINOR+1}.0.dev0
167 git push upstream MAJOR.{MINOR+1}.0.dev0
168
169 #. Send an email announcement with the contents from::
170
171 doc/en/announce/release-<VERSION>.rst
172
173 To the following mailing lists:
174
175 * [email protected]
176
177 And announce it with the ``#pytest`` hashtag on:
178
179 * `Bluesky <https://bsky.app>`_
180 * `Fosstodon <https://fosstodon.org>`_
181 * `Twitter/X <https://x.com>`_