Skip to content

Commit 005690b

Browse files
Add template for prereleases (#9165)
Fix #8820
1 parent 1e9e16d commit 005690b

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Ahn Ki-Wook
1313
Akiomi Kamakura
1414
Alan Velasco
1515
Alexander Johnson
16+
Alexander King
1617
Alexei Kozlenok
1718
Allan Feldman
1819
Aly Sivji

scripts/prepare-release-pr.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ def prepare_release_pr(
5454

5555
check_call(["git", "checkout", f"origin/{base_branch}"])
5656

57+
changelog = Path("changelog")
58+
59+
features = list(changelog.glob("*.feature.rst"))
60+
breaking = list(changelog.glob("*.breaking.rst"))
61+
is_feature_release = bool(features or breaking)
62+
5763
try:
58-
version = find_next_version(base_branch, is_major, prerelease)
64+
version = find_next_version(
65+
base_branch, is_major, is_feature_release, prerelease
66+
)
5967
except InvalidFeatureRelease as e:
6068
print(f"{Fore.RED}{e}")
6169
raise SystemExit(1)
@@ -80,9 +88,24 @@ def prepare_release_pr(
8088

8189
print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} created.")
8290

91+
if prerelease:
92+
template_name = "release.pre.rst"
93+
elif is_feature_release:
94+
template_name = "release.minor.rst"
95+
else:
96+
template_name = "release.patch.rst"
97+
8398
# important to use tox here because we have changed branches, so dependencies
8499
# might have changed as well
85-
cmdline = ["tox", "-e", "release", "--", version, "--skip-check-links"]
100+
cmdline = [
101+
"tox",
102+
"-e",
103+
"release",
104+
"--",
105+
version,
106+
template_name,
107+
"--skip-check-links",
108+
]
86109
print("Running", " ".join(cmdline))
87110
run(
88111
cmdline,
@@ -107,7 +130,9 @@ def prepare_release_pr(
107130
print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.")
108131

109132

110-
def find_next_version(base_branch: str, is_major: bool, prerelease: str) -> str:
133+
def find_next_version(
134+
base_branch: str, is_major: bool, is_feature_release: bool, prerelease: str
135+
) -> str:
111136
output = check_output(["git", "tag"], encoding="UTF-8")
112137
valid_versions = []
113138
for v in output.splitlines():
@@ -118,12 +143,6 @@ def find_next_version(base_branch: str, is_major: bool, prerelease: str) -> str:
118143
valid_versions.sort()
119144
last_version = valid_versions[-1]
120145

121-
changelog = Path("changelog")
122-
123-
features = list(changelog.glob("*.feature.rst"))
124-
breaking = list(changelog.glob("*.breaking.rst"))
125-
is_feature_release = features or breaking
126-
127146
if is_major:
128147
return f"{last_version[0]+1}.0.0{prerelease}"
129148
elif is_feature_release:

scripts/release.pre.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
pytest-{version}
2+
=======================================
3+
4+
The pytest team is proud to announce the {version} prerelease!
5+
6+
This is a prerelease, not intended for production use, but to test the upcoming features and improvements
7+
in order to catch any major problems before the final version is released to the major public.
8+
9+
We appreciate your help testing this out before the final release, making sure to report any
10+
regressions to our issue tracker:
11+
12+
https://github.com/pytest-dev/pytest/issues
13+
14+
When doing so, please include the string ``[prerelease]`` in the title.
15+
16+
You can upgrade from PyPI via:
17+
18+
pip install pytest=={version}
19+
20+
Users are encouraged to take a look at the CHANGELOG carefully:
21+
22+
https://docs.pytest.org/en/stable/changelog.html
23+
24+
Thanks to all the contributors to this release:
25+
26+
{contributors}
27+
28+
Happy testing,
29+
The pytest Development Team

scripts/release.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from colorama import init
1111

1212

13-
def announce(version):
13+
def announce(version, template_name):
1414
"""Generates a new release announcement entry in the docs."""
1515
# Get our list of authors
1616
stdout = check_output(["git", "describe", "--abbrev=0", "--tags"])
@@ -22,9 +22,6 @@ def announce(version):
2222

2323
contributors = {name for name in stdout.splitlines() if not name.endswith("[bot]")}
2424

25-
template_name = (
26-
"release.minor.rst" if version.endswith(".0") else "release.patch.rst"
27-
)
2825
template_text = (
2926
Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
3027
)
@@ -81,9 +78,9 @@ def check_links():
8178
check_call(["tox", "-e", "docs-checklinks"])
8279

8380

84-
def pre_release(version, *, skip_check_links):
81+
def pre_release(version, template_name, *, skip_check_links):
8582
"""Generates new docs, release announcements and creates a local tag."""
86-
announce(version)
83+
announce(version, template_name)
8784
regen(version)
8885
changelog(version, write_out=True)
8986
fix_formatting()
@@ -108,9 +105,16 @@ def main():
108105
init(autoreset=True)
109106
parser = argparse.ArgumentParser()
110107
parser.add_argument("version", help="Release version")
108+
parser.add_argument(
109+
"template_name", help="Name of template file to use for release announcement"
110+
)
111111
parser.add_argument("--skip-check-links", action="store_true", default=False)
112112
options = parser.parse_args()
113-
pre_release(options.version, skip_check_links=options.skip_check_links)
113+
pre_release(
114+
options.version,
115+
options.template_name,
116+
skip_check_links=options.skip_check_links,
117+
)
114118

115119

116120
if __name__ == "__main__":

0 commit comments

Comments
 (0)