Skip to content

Add template for prereleases #9165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Ahn Ki-Wook
Akiomi Kamakura
Alan Velasco
Alexander Johnson
Alexander King
Alexei Kozlenok
Allan Feldman
Aly Sivji
Expand Down
37 changes: 28 additions & 9 deletions scripts/prepare-release-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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():
Expand All @@ -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:
Expand Down
29 changes: 29 additions & 0 deletions scripts/release.pre.rst
Original file line number Diff line number Diff line change
@@ -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
18 changes: 11 additions & 7 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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"])
Expand All @@ -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")
)
Expand Down Expand Up @@ -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()
Expand All @@ -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__":
Expand Down