Skip to content

Commit 21a186b

Browse files
scripts: Use release branch for changelog URL (#9380)
* scripts: Use release branch for changelog URL With a prerelease, /stable won't show the correct changelog. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5cb50fa commit 21a186b

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

scripts/prepare-release-pr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ def prepare_release_pr(
9090

9191
if prerelease:
9292
template_name = "release.pre.rst"
93+
doc_version = release_branch
9394
elif is_feature_release:
9495
template_name = "release.minor.rst"
96+
doc_version = "" # unused in template
9597
else:
9698
template_name = "release.patch.rst"
99+
doc_version = "" # unused in template
97100

98101
# important to use tox here because we have changed branches, so dependencies
99102
# might have changed as well
@@ -104,6 +107,7 @@ def prepare_release_pr(
104107
"--",
105108
version,
106109
template_name,
110+
doc_version,
107111
"--skip-check-links",
108112
]
109113
print("Running", " ".join(cmdline))

scripts/release.pre.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ You can upgrade from PyPI via:
1919

2020
Users are encouraged to take a look at the CHANGELOG carefully:
2121

22-
https://docs.pytest.org/en/stable/changelog.html
22+
https://docs.pytest.org/en/{doc_version}/changelog.html
2323

2424
Thanks to all the contributors to this release:
2525

scripts/release.py

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

1212

13-
def announce(version, template_name):
13+
def announce(version, template_name, doc_version):
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"])
@@ -31,7 +31,9 @@ def announce(version, template_name):
3131
)
3232

3333
contributors_text = "\n".join(f"* {name}" for name in sorted(contributors)) + "\n"
34-
text = template_text.format(version=version, contributors=contributors_text)
34+
text = template_text.format(
35+
version=version, contributors=contributors_text, doc_version=doc_version
36+
)
3537

3638
target = Path(__file__).parent.joinpath(f"../doc/en/announce/release-{version}.rst")
3739
target.write_text(text, encoding="UTF-8")
@@ -82,9 +84,9 @@ def check_links():
8284
check_call(["tox", "-e", "docs-checklinks"])
8385

8486

85-
def pre_release(version, template_name, *, skip_check_links):
87+
def pre_release(version, template_name, doc_version, *, skip_check_links):
8688
"""Generates new docs, release announcements and creates a local tag."""
87-
announce(version, template_name)
89+
announce(version, template_name, doc_version)
8890
regen(version)
8991
changelog(version, write_out=True)
9092
fix_formatting()
@@ -112,11 +114,15 @@ def main():
112114
parser.add_argument(
113115
"template_name", help="Name of template file to use for release announcement"
114116
)
117+
parser.add_argument(
118+
"doc_version", help="For prereleases, the version to link to in the docs"
119+
)
115120
parser.add_argument("--skip-check-links", action="store_true", default=False)
116121
options = parser.parse_args()
117122
pre_release(
118123
options.version,
119124
options.template_name,
125+
options.doc_version,
120126
skip_check_links=options.skip_check_links,
121127
)
122128

0 commit comments

Comments
 (0)