Skip to content

Commit

Permalink
Use current version for release notes generation (#1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Jan 25, 2024
1 parent 1845ce1 commit 72a45f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ How to release a new version of Python Holidays
- switch to ``beta`` branch and pull the most recent changes
from https://github.com/vacanza/python-holidays remote ``beta`` branch.
- generate release notes by running the following script
``scripts/generate_release_notes.py -t <version>``, where <version> is the
value of tag/version you're going to release, e.g. 0.39
``scripts/generate_release_notes.py``
- insert the script's output into the top of ``CHANGES`` file
(see previous release notes for consistent formatting)
- commit the updated ``CHANGES`` file to ``beta`` branch with the following
Expand Down
22 changes: 10 additions & 12 deletions scripts/generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# flake8: noqa: T201

import argparse
import os
import re
import sys
from datetime import date
from pathlib import Path
from typing import Dict, Set
Expand All @@ -24,6 +24,9 @@
from github import Github
from github.GithubException import UnknownObjectException

sys.path.append(f"{Path.cwd()}")
import holidays

BRANCH_NAME = "beta"
HEADER_TEMPLATE = """
Version {version}
Expand All @@ -39,7 +42,7 @@ class ReleaseNotesGenerator:
"""
Generates release notes based on local git commits and GitHub PRs metadata.
Usage example: scripts/generate_release_notes.py -t 0.24
Usage example: scripts/generate_release_notes.py
"""

def __init__(self) -> None:
Expand Down Expand Up @@ -69,13 +72,6 @@ def __init__(self) -> None:
nargs="+",
type=int,
)
arg_parser.add_argument(
"-t",
"--tag",
help="New release tag",
required=True,
type=str,
)
arg_parser.add_argument(
"-v",
"--verbose",
Expand All @@ -85,12 +81,14 @@ def __init__(self) -> None:
)
self.args = arg_parser.parse_args()

self.local_repo = Repo(os.getcwd())
self.local_repo = Repo(Path.cwd())
self.remote_repo = Github(self.github_token).get_repo(REPOSITORY_NAME)

self.previous_commits: Set[str] = set()
self.pull_requests: Dict[int, str] = {}

self.tag = holidays.__version__

try:
latest_tag = self.remote_repo.get_tags()[0]
self.latest_tag_name = latest_tag.name
Expand Down Expand Up @@ -146,7 +144,7 @@ def add_pull_request(self, pull_request):

# Skip failed release attempt PRs, version upgrades.
pr_title = pull_request.title
skip_titles = (f"v.{self.args.tag}", "Bump", "Revert")
skip_titles = (f"v.{self.tag}", "Bump", "Revert")
for skip_title in skip_titles:
if pr_title.startswith(skip_title):
return None
Expand Down Expand Up @@ -246,7 +244,7 @@ def print_release_notes(self):
HEADER_TEMPLATE.format(
day=today.day,
month=today.strftime("%B"),
version=self.args.tag,
version=self.tag,
year=today.year,
)
)
Expand Down

0 comments on commit 72a45f4

Please sign in to comment.