From 809ae9aac3af44abbad89d38b7a4dd00fbb2390b Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Mon, 3 Feb 2025 19:03:40 +1100 Subject: [PATCH] chore: use --since in release_notes.py (#6915) The semantics of `release_notes.py` was slightly confusing. It is meant to be run a `script/release_notes.py v4.15.0` on the `releases/v4.16.0` branch. To help, I've changed the usage to `script/release_notes.py --since v4.15.0`. --- doc/dev/release_checklist.md | 8 +++++--- script/release_checklist.py | 2 +- script/release_notes.py | 12 ++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/dev/release_checklist.md b/doc/dev/release_checklist.md index 0500032df9..51a14e8105 100644 --- a/doc/dev/release_checklist.md +++ b/doc/dev/release_checklist.md @@ -102,7 +102,7 @@ We'll use `v4.6.0` as the intended release version as a running example. - Toolchain bump PR including updated Lake manifest - Create and push the tag - Merge the tag into `stable` -- Run `scripts/release_checklist.py v4.6.0` to check that everything is in order. +- Run `script/release_checklist.py v4.6.0` to check that everything is in order. - The `v4.6.0` section of `RELEASES.md` is out of sync between `releases/v4.6.0` and `master`. This should be reconciled: - Replace the `v4.6.0` section on `master` with the `v4.6.0` section on `releases/v4.6.0` @@ -252,8 +252,10 @@ Please read https://leanprover-community.github.io/contribute/tags_and_branches. Release notes are automatically generated from the commit history, using `script/release_notes.py`. -Run this as `script/release_notes.py v4.6.0`, where `v4.6.0` is the *previous* release version. This will generate output -for all commits since that tag. Note that there is output on both stderr, which should be manually reviewed, +Run this as `script/release_notes.py --since v4.6.0`, where `v4.6.0` is the *previous* release version. +This script should be run on the `releases/v4.7.0` branch. +This will generate output for all commits since that tag. +Note that there is output on both stderr, which should be manually reviewed, and on stdout, which should be manually copied to `RELEASES.md`. There can also be pre-written entries in `./releases_drafts`, which should be all incorporated in the release notes and then deleted from the branch. diff --git a/script/release_checklist.py b/script/release_checklist.py index ed6922a8ee..a13042175a 100755 --- a/script/release_checklist.py +++ b/script/release_checklist.py @@ -185,7 +185,7 @@ def main(): previous_minor_version = version_minor - 1 previous_stable_branch = f"releases/v{version_major}.{previous_minor_version}.0" previous_release = f"v{version_major}.{previous_minor_version}.0" - print(f" ❌ Release notes not published. Please run `script/release_notes.py {previous_release}` on branch `{previous_stable_branch}`.") + print(f" ❌ Release notes not published. Please run `script/release_notes.py --since {previous_release}` on branch `{branch_name}`.") else: print(f" ❌ Release page for {toolchain} does not exist") diff --git a/script/release_notes.py b/script/release_notes.py index d8bb03ca5d..8c97a0395d 100755 --- a/script/release_notes.py +++ b/script/release_notes.py @@ -5,6 +5,7 @@ import re import json import requests import subprocess +import argparse from collections import defaultdict from git import Repo @@ -65,20 +66,19 @@ def format_markdown_description(pr_number, description): return f"{link} {description}" def main(): - if len(sys.argv) != 2: - sys.stderr.write("Usage: script.py \n") - sys.exit(1) + parser = argparse.ArgumentParser(description='Generate release notes from Git commits') + parser.add_argument('--since', required=True, help='Git tag to generate release notes since') + args = parser.parse_args() - tag = sys.argv[1] try: repo = Repo(".") except Exception as e: sys.stderr.write(f"Error opening Git repository: {e}\n") sys.exit(1) - commits = get_commits_since_tag(repo, tag) + commits = get_commits_since_tag(repo, args.since) - sys.stderr.write(f"Found {len(commits)} commits since tag {tag}:\n") + sys.stderr.write(f"Found {len(commits)} commits since tag {args.since}:\n") for commit_hash, first_line, _ in commits: sys.stderr.write(f"- {commit_hash}: {first_line}\n")