Skip to content
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

Use current version for release notes generation #1661

Merged
merged 1 commit into from
Jan 25, 2024
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
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