Add template for prereleases (#9165)

Fix #8820
This commit is contained in:
Alexander King 2021-10-22 09:00:00 -04:00 committed by GitHub
parent 1e9e16d829
commit 005690bd67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 16 deletions

View File

@ -13,6 +13,7 @@ Ahn Ki-Wook
Akiomi Kamakura
Alan Velasco
Alexander Johnson
Alexander King
Alexei Kozlenok
Allan Feldman
Aly Sivji

View File

@ -54,8 +54,16 @@ def prepare_release_pr(
check_call(["git", "checkout", f"origin/{base_branch}"])
changelog = Path("changelog")
features = list(changelog.glob("*.feature.rst"))
breaking = list(changelog.glob("*.breaking.rst"))
is_feature_release = bool(features or breaking)
try:
version = find_next_version(base_branch, is_major, prerelease)
version = find_next_version(
base_branch, is_major, is_feature_release, prerelease
)
except InvalidFeatureRelease as e:
print(f"{Fore.RED}{e}")
raise SystemExit(1)
@ -80,9 +88,24 @@ def prepare_release_pr(
print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} created.")
if prerelease:
template_name = "release.pre.rst"
elif is_feature_release:
template_name = "release.minor.rst"
else:
template_name = "release.patch.rst"
# important to use tox here because we have changed branches, so dependencies
# might have changed as well
cmdline = ["tox", "-e", "release", "--", version, "--skip-check-links"]
cmdline = [
"tox",
"-e",
"release",
"--",
version,
template_name,
"--skip-check-links",
]
print("Running", " ".join(cmdline))
run(
cmdline,
@ -107,7 +130,9 @@ def prepare_release_pr(
print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.")
def find_next_version(base_branch: str, is_major: bool, prerelease: str) -> str:
def find_next_version(
base_branch: str, is_major: bool, is_feature_release: bool, prerelease: str
) -> str:
output = check_output(["git", "tag"], encoding="UTF-8")
valid_versions = []
for v in output.splitlines():
@ -118,12 +143,6 @@ def find_next_version(base_branch: str, is_major: bool, prerelease: str) -> str:
valid_versions.sort()
last_version = valid_versions[-1]
changelog = Path("changelog")
features = list(changelog.glob("*.feature.rst"))
breaking = list(changelog.glob("*.breaking.rst"))
is_feature_release = features or breaking
if is_major:
return f"{last_version[0]+1}.0.0{prerelease}"
elif is_feature_release:

29
scripts/release.pre.rst Normal file
View File

@ -0,0 +1,29 @@
pytest-{version}
=======================================
The pytest team is proud to announce the {version} prerelease!
This is a prerelease, not intended for production use, but to test the upcoming features and improvements
in order to catch any major problems before the final version is released to the major public.
We appreciate your help testing this out before the final release, making sure to report any
regressions to our issue tracker:
https://github.com/pytest-dev/pytest/issues
When doing so, please include the string ``[prerelease]`` in the title.
You can upgrade from PyPI via:
pip install pytest=={version}
Users are encouraged to take a look at the CHANGELOG carefully:
https://docs.pytest.org/en/stable/changelog.html
Thanks to all the contributors to this release:
{contributors}
Happy testing,
The pytest Development Team

View File

@ -10,7 +10,7 @@ from colorama import Fore
from colorama import init
def announce(version):
def announce(version, template_name):
"""Generates a new release announcement entry in the docs."""
# Get our list of authors
stdout = check_output(["git", "describe", "--abbrev=0", "--tags"])
@ -22,9 +22,6 @@ def announce(version):
contributors = {name for name in stdout.splitlines() if not name.endswith("[bot]")}
template_name = (
"release.minor.rst" if version.endswith(".0") else "release.patch.rst"
)
template_text = (
Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
)
@ -81,9 +78,9 @@ def check_links():
check_call(["tox", "-e", "docs-checklinks"])
def pre_release(version, *, skip_check_links):
def pre_release(version, template_name, *, skip_check_links):
"""Generates new docs, release announcements and creates a local tag."""
announce(version)
announce(version, template_name)
regen(version)
changelog(version, write_out=True)
fix_formatting()
@ -108,9 +105,16 @@ def main():
init(autoreset=True)
parser = argparse.ArgumentParser()
parser.add_argument("version", help="Release version")
parser.add_argument(
"template_name", help="Name of template file to use for release announcement"
)
parser.add_argument("--skip-check-links", action="store_true", default=False)
options = parser.parse_args()
pre_release(options.version, skip_check_links=options.skip_check_links)
pre_release(
options.version,
options.template_name,
skip_check_links=options.skip_check_links,
)
if __name__ == "__main__":