Skip to content

fix #8820 - ensure the release scripts are ware of release candidates #8825

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

Closed
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 changelog/8820.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure prereleases correctly pick the matching changelog template.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an user-facing bugfix, so this seems confusing.

10 changes: 6 additions & 4 deletions scripts/prepare-release-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from colorama import Fore
from colorama import init
from github3.repos import Repository
from packaging.version import Version


class InvalidFeatureRelease(Exception):
Expand Down Expand Up @@ -113,7 +114,7 @@ def find_next_version(base_branch: str, is_major: bool, prerelease: str) -> str:
for v in output.splitlines():
m = re.match(r"\d.\d.\d+$", v.strip())
if m:
valid_versions.append(tuple(int(x) for x in v.split(".")))
valid_versions.append(Version(v))

valid_versions.sort()
last_version = valid_versions[-1]
Expand All @@ -124,12 +125,13 @@ def find_next_version(base_branch: str, is_major: bool, prerelease: str) -> str:
breaking = list(changelog.glob("*.breaking.rst"))
is_feature_release = features or breaking

# TODO @RonnyPfannschmidt - setuptools_scm version of that
if is_major:
return f"{last_version[0]+1}.0.0{prerelease}"
return f"{last_version.major+1}.0.0{prerelease}"
elif is_feature_release:
return f"{last_version[0]}.{last_version[1] + 1}.0{prerelease}"
return f"{last_version.major}.{last_version.minor[1] + 1}.0{prerelease}"
else:
return f"{last_version[0]}.{last_version[1]}.{last_version[2] + 1}{prerelease}"
return f"{last_version.major}.{last_version.minor}.{last_version.patch + 1}{prerelease}"


def main() -> None:
Expand Down
17 changes: 8 additions & 9 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

from colorama import Fore
from colorama import init
from packaging.version import Version


def announce(version):
def announce(version: Version):
"""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 +23,7 @@ def announce(version):

contributors = set(stdout.splitlines())

template_name = (
"release.minor.rst" if version.endswith(".0") else "release.patch.rst"
)
template_name = "release.minor.rst" if version.minor == 0 else "release.patch.rst"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen my suggestions:

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed it before, will check the details, thanks

template_text = (
Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
)
Expand Down Expand Up @@ -63,7 +62,7 @@ def regen(version):
print(f"{Fore.CYAN}[generate.regen] {Fore.RESET}Updating docs")
check_call(
["tox", "-e", "regen"],
env={**os.environ, "SETUPTOOLS_SCM_PRETEND_VERSION": version},
env={**os.environ, "SETUPTOOLS_SCM_PRETEND_VERSION": str(version)},
)


Expand All @@ -81,7 +80,7 @@ def check_links():
check_call(["tox", "-e", "docs-checklinks"])


def pre_release(version, *, skip_check_links):
def pre_release(version: Version, *, skip_check_links):
"""Generates new docs, release announcements and creates a local tag."""
announce(version)
regen(version)
Expand All @@ -99,9 +98,9 @@ def pre_release(version, *, skip_check_links):
print("Please push your branch and open a PR.")


def changelog(version, write_out=False):
def changelog(version: Version, write_out=False):
addopts = [] if write_out else ["--draft"]
check_call(["towncrier", "--yes", "--version", version] + addopts)
check_call(["towncrier", "--yes", "--version", str(version)] + addopts)


def main():
Expand All @@ -110,7 +109,7 @@ def main():
parser.add_argument("version", help="Release version")
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(Version(options.version), skip_check_links=options.skip_check_links)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ deps =
github3.py
pre-commit>=2.9.3
wheel
packaging
towncrier
commands = python scripts/release.py {posargs}

Expand Down