Skip to content

Commit 50a1cf6

Browse files
authored
DEV: Make make_release.py easier to configure (#2348)
1 parent 40bc577 commit 50a1cf6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

make_release.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Internal tool to update the changelog."""
1+
"""Internal tool to update the CHANGELOG."""
22

33
import json
44
import subprocess
@@ -9,6 +9,11 @@
99

1010
from rich.prompt import Prompt
1111

12+
GH_ORG = "py-pdf"
13+
GH_PROJECT = "pypdf"
14+
VERSION_FILE_PATH = "pypdf/_version.py"
15+
CHANGELOG_FILE_PATH = "CHANGELOG.md"
16+
1217

1318
@dataclass(frozen=True)
1419
class Change:
@@ -41,7 +46,7 @@ def main(changelog_path: str) -> None:
4146

4247
today = datetime.now(tz=timezone.utc)
4348
header = f"## Version {new_version}, {today:%Y-%m-%d}\n"
44-
url = f"https://github.com/py-pdf/pypdf/compare/{git_tag}...{new_version}"
49+
url = f"https://github.com/{GH_ORG}/{GH_PROJECT}/compare/{git_tag}...{new_version}"
4550
trailer = f"\n[Full Changelog]({url})\n\n"
4651
new_entry = header + changes + trailer
4752
print(new_entry)
@@ -61,8 +66,8 @@ def main(changelog_path: str) -> None:
6166
def print_instructions(new_version: str) -> None:
6267
"""Print release instructions."""
6368
print("=" * 80)
64-
print(f"☑ _version.py was adjusted to '{new_version}'")
65-
print("☑ CHANGELOG.md was adjusted")
69+
print(f"☑ {VERSION_FILE_PATH} was adjusted to '{new_version}'")
70+
print(f"☑ {CHANGELOG_FILE_PATH} was adjusted")
6671
print("")
6772
print("Now run:")
6873
print(" git commit -eF RELEASE_COMMIT_MSG.md")
@@ -73,7 +78,7 @@ def print_instructions(new_version: str) -> None:
7378

7479
def adjust_version_py(version: str) -> None:
7580
"""Adjust the __version__ string."""
76-
with open("pypdf/_version.py", "w") as fp:
81+
with open(VERSION_FILE_PATH, "w") as fp:
7782
fp.write(f'__version__ = "{version}"\n')
7883

7984

@@ -93,8 +98,7 @@ def get_version_interactive(new_version: str, changes: str) -> str:
9398

9499
def is_semantic_version(version: str) -> bool:
95100
"""Check if the given version is a semantic version."""
96-
# It's not so important to cover the edge-cases like pre-releases
97-
# This is meant for pypdf only and we don't make pre-releases
101+
# This doesn't cover the edge-cases like pre-releases
98102
if version.count(".") != 2:
99103
return False
100104
try:
@@ -284,7 +288,7 @@ def get_author_mapping(line_count: int) -> Dict[str, str]:
284288
mapping: Dict[str, str] = {}
285289
for _ in range(0, line_count, per_page):
286290
with urllib.request.urlopen( # noqa: S310
287-
f"https://api.github.com/repos/py-pdf/pypdf/commits?per_page={per_page}&page={page}"
291+
f"https://api.github.com/repos/{GH_ORG}/{GH_PROJECT}/commits?per_page={per_page}&page={page}"
288292
) as response:
289293
commits = json.loads(response.read())
290294
page += 1
@@ -366,4 +370,4 @@ def parse_commit_line(line: str, authors: Dict[str, str]) -> Change:
366370

367371

368372
if __name__ == "__main__":
369-
main("CHANGELOG.md")
373+
main(CHANGELOG_FILE_PATH)

0 commit comments

Comments
 (0)