Skip to content

Commit b6125d9

Browse files
Merge pull request #2397 from nicoddemus/announce-task
Introduce a task to generate the announcement file for releases
2 parents daca618 + 66ba3c3 commit b6125d9

File tree

6 files changed

+117
-5
lines changed

6 files changed

+117
-5
lines changed

HOWTORELEASE.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
How to release pytest
22
--------------------------------------------
33

4-
Note: this assumes you have already registered on pypi.
4+
Note: this assumes you have already registered on PyPI and you have
5+
`invoke <https://pypi.org/project/invoke/>`_ installed.
56

67
#. Check and finalize ``CHANGELOG.rst``.
78

8-
#. Write ``doc/en/announce/release-VERSION.txt`` and include
9-
it in ``doc/en/announce/index.txt``. Run this command to list names of authors involved::
9+
#. Generate a new release announcement::
1010

11-
git log $(git describe --abbrev=0 --tags)..HEAD --format='%aN' | sort -u
11+
invoke generate.announce VERSION
12+
13+
Feel free to modify the generated files before committing.
1214

1315
#. Regenerate the docs examples using tox::
1416

15-
tox -e regen
17+
tox -e regen
1618

1719
#. At this point, open a PR named ``release-X`` so others can help find regressions or provide suggestions.
1820

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ recursive-include extra *.py
2020
graft testing
2121
graft doc
2222
prune doc/en/_build
23+
graft tasks
2324

2425
exclude _pytest/impl
2526

tasks/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
Invoke tasks to help with pytest development and release process.
3+
"""
4+
5+
import invoke
6+
7+
from . import generate
8+
9+
ns = invoke.Collection(generate)

tasks/generate.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from pathlib import Path
2+
from subprocess import check_output
3+
4+
import invoke
5+
6+
7+
@invoke.task(help={
8+
'version': 'version being released',
9+
})
10+
def announce(ctx, version):
11+
"""Generates a new release announcement entry in the docs."""
12+
print("[generate.announce] Generating Announce")
13+
14+
# Get our list of authors
15+
print("[generate.announce] Collecting author names")
16+
17+
stdout = check_output(["git", "describe", "--abbrev=0", '--tags'])
18+
stdout = stdout.decode('utf-8')
19+
last_version = stdout.strip()
20+
21+
stdout = check_output(["git", "log", "{}..HEAD".format(last_version), "--format=%aN"])
22+
stdout = stdout.decode('utf-8')
23+
24+
contributors = set(stdout.splitlines())
25+
26+
template_name = 'release.minor.rst' if version.endswith('.0') else 'release.patch.rst'
27+
template_text = Path(__file__).parent.joinpath(template_name).read_text(encoding='UTF-8')
28+
29+
contributors_text = '\n'.join('* {}'.format(name) for name in sorted(contributors)) + '\n'
30+
text = template_text.format(version=version, contributors=contributors_text)
31+
32+
target = Path(__file__).joinpath('../../doc/en/announce/release-{}.rst'.format(version))
33+
target.write_text(text, encoding='UTF-8')
34+
print("[generate.announce] Generated {}".format(target.name))
35+
36+
# Update index with the new release entry
37+
index_path = Path(__file__).joinpath('../../doc/en/announce/index.rst')
38+
lines = index_path.read_text(encoding='UTF-8').splitlines()
39+
indent = ' '
40+
for index, line in enumerate(lines):
41+
if line.startswith('{}release-'.format(indent)):
42+
new_line = indent + target.stem
43+
if line != new_line:
44+
lines.insert(index, new_line)
45+
index_path.write_text('\n'.join(lines) + '\n', encoding='UTF-8')
46+
print("[generate.announce] Updated {}".format(index_path.name))
47+
else:
48+
print("[generate.announce] Skip {} (already contains release)".format(index_path.name))
49+
break
50+
51+
print()
52+
print('Please review the generated files and commit with:')
53+
print(' git commit -a -m "Generate new release announcement for {}'.format(version))
54+
55+
56+

tasks/release.minor.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
pytest-{version}
2+
=======================================
3+
4+
The pytest team is proud to announce the {version} release!
5+
6+
pytest is a mature Python testing tool with more than a 1600 tests
7+
against itself, passing on many different interpreters and platforms.
8+
9+
This release contains a bugs fixes and improvements, so users are encouraged
10+
to take a look at the CHANGELOG:
11+
12+
http://doc.pytest.org/en/latest/changelog.html
13+
14+
For complete documentation, please visit:
15+
16+
http://docs.pytest.org
17+
18+
As usual, you can upgrade from pypi via:
19+
20+
pip install -U pytest
21+
22+
Thanks to all who contributed to this release, among them:
23+
24+
{contributors}
25+
26+
Happy testing,
27+
The Pytest Development Team

tasks/release.patch.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pytest-{version}
2+
=======================================
3+
4+
pytest {version} has just been released to PyPI.
5+
6+
This is a bug-fix release, being a drop-in replacement. To upgrade::
7+
8+
pip install --upgrade pytest
9+
10+
The full changelog is available at http://doc.pytest.org/en/latest/changelog.html.
11+
12+
Thanks to all who contributed to this release, among them:
13+
14+
{contributors}
15+
16+
Happy testing,
17+
The pytest Development Team

0 commit comments

Comments
 (0)