From 04df7a1d05c2669d57485e25643f5c7c6a45d261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Thu, 2 Oct 2025 10:51:24 +0200 Subject: [PATCH] feat: add --add-version-header flag to build_changelog.py Add optional flag to prepend version header and adjust heading levels, useful for projects that want to include changelogs in their docs with proper heading hierarchy. When enabled: - Adds '# vX.Y.Z' header at the top - Adjusts '# Contributors' to '## Contributors' - Adjusts '# Changelog' to '## Changelog' This keeps the default behavior unchanged while allowing docs-oriented projects (like gptme) to generate properly formatted release notes. --- scripts/build_changelog.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/build_changelog.py b/scripts/build_changelog.py index 1d0160a3..a974fb5f 100755 --- a/scripts/build_changelog.py +++ b/scripts/build_changelog.py @@ -63,6 +63,11 @@ def main(): parser.add_argument( "--output", default="changelog.md", help="Path to output changelog" ) + parser.add_argument( + "--add-version-header", + action="store_true", + help="Add version header and adjust heading levels for docs", + ) # parse args args = parser.parse_args() @@ -88,6 +93,7 @@ def main(): commit_range=(since, until), output_path=args.output, repo_order=repo_order, + add_version_header=args.add_version_header, ) @@ -352,6 +358,7 @@ def build( output_path: str, repo_order: List[str], filter_types: Optional[List[str]] = None, + add_version_header: bool = False, ): # provides a commit summary for the repo and subrepos, recursively looking up subrepos # NOTE: this must be done *before* `get_all_contributors` is called, @@ -423,6 +430,12 @@ def build( if repo == "activitywatch": output = output.replace("# activitywatch", "# activitywatch (bundle repo)") + + if add_version_header: + output = f"# {tag}\n\n" + output + output = output.replace("\n# Contributors\n", "\n## Contributors\n") + output = output.replace("\n# Changelog\n", "\n## Changelog\n") + with open(output_path, "w") as f: f.write(output) print(f"Wrote {len(output.splitlines())} lines to {output_path}")