Files
HashTool/eng/release-notes.py
T
poli0981andClaude Opus 5.5 e7a4830c41 ci: security scanning, release automation with an upgrade gate, Dependabot
- ci.yml: -warnaserror builds (NuGet audit included), Core coverage gate
  (80%), headless smoke test, translation check and a single `ci-ok`
  status for branch protection.
- security.yml: vulnerable packages (JSON report checked explicitly),
  licence allowlist via nuget-license, gitleaks, actionlint and zizmor.
- dependency-review.yml, dependency-submission.yml (full NuGet graph for
  Dependabot alerts) and scorecard.yml.
- release.yml: manual release with a dry-run mode and PR dry runs; builds
  win, osx (arm64), osx-x64 and linux with vpk, smoke-tests every
  published build, checks package identity, updates a real 1.1.3 portable
  install with its own updater before anything is published, builds the
  NativeAOT CLI for four platforms, adds SBOMs, SHA256SUMS and build
  provenance, publishes draft-then-verify, then announces on Discord.
- Notification workflows: explicit workflow names instead of "*", pinned
  to a commit of poli0981/.github, explicit secrets instead of inherit,
  fork runs filtered out; release-pineline.yml renamed.
- dependabot.yml (NuGet, .NET SDK, Actions, grouped), CODEOWNERS, issue
  forms and a pull request template.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 13:16:40 +07:00

57 lines
2.2 KiB
Python

#!/usr/bin/env python3
"""Extracts the notes of one version from CHANGELOG.md (Keep a Changelog format).
python -I eng/release-notes.py 1.2.0 [--changelog CHANGELOG.md] [--require-date] > notes.md
Prints the body of the "## [<version>]" section and fails when it is missing or empty, so nothing ships without notes.
--require-date additionally insists on a dated heading ("## [1.2.0] - 2026-10-15"), which a real release needs.
"""
import argparse
import re
import sys
from pathlib import Path
MAX_LENGTH = 20_000
def find_section(changelog: str, version: str) -> tuple[str, str] | None:
heading = re.compile(rf"^## \[{re.escape(version)}\][^\n]*$", re.MULTILINE)
match = heading.search(changelog)
if match is None:
return None
following = re.compile(r"^## \[", re.MULTILINE).search(changelog, match.end())
body = changelog[match.end():following.start() if following else len(changelog)]
# Link reference definitions ([1.2.0]: https://...) belong to the whole file.
body = re.sub(r"^\[[^\]]+\]:\s*\S+\s*$", "", body, flags=re.MULTILINE)
# A horizontal rule separating versions is not part of the notes.
body = re.sub(r"\n-{3,}\s*$", "", body.strip())
return match.group(0), body.strip()
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("version")
parser.add_argument("--changelog", default="CHANGELOG.md")
parser.add_argument("--require-date", action="store_true")
args = parser.parse_args()
section = find_section(Path(args.changelog).read_text(encoding="utf-8"), args.version)
if section is None or not section[1]:
print(f"::error::CHANGELOG has no notes for {args.version}", file=sys.stderr)
return 1
heading, notes = section
if args.require_date and not re.search(r"- \d{4}-\d{2}-\d{2}\s*$", heading):
print(f"::error::The CHANGELOG heading '{heading}' has no release date", file=sys.stderr)
return 1
if len(notes) > MAX_LENGTH:
print(f"::error::Release notes for {args.version} are {len(notes)} characters (limit {MAX_LENGTH})", file=sys.stderr)
return 1
sys.stdout.reconfigure(encoding="utf-8")
print(notes)
return 0
if __name__ == "__main__":
sys.exit(main())