Skip to content

Commit

Permalink
Auto-generate release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanlensky committed Oct 28, 2024
1 parent b35617e commit ef81958
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
run: uv python install
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Generate API reference docs
- name: Auto-generate docs
run: |
uv run python scripts/mkdocs_generate_reference.py
uv run python scripts/mkdocs_generate_release_notes.py
- name: Deploy to GitHub Pages
run: uv run mkdocs gh-deploy --force
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# mkdocs
# mkdocs build
site/

# auto-generated docs
docs/reference
docs/release-notes.md

# uv/pyenv
.python-version
Expand Down
32 changes: 32 additions & 0 deletions scripts/mkdocs_generate_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env -S uv run
from pathlib import Path

REPO_ROOT = Path(__file__).parent.parent
CHANGELOG_MD = REPO_ROOT / "CHANGELOG.md"
RELEASE_NOTES_MD = REPO_ROOT / "docs" / "release-notes.md"


def get_releases() -> str:
with CHANGELOG_MD.open() as f:
changelog_md = f.read()

sections = changelog_md.split("\n## ")[1:]
unreleased = sections.pop(0)
# small sanity check
if not unreleased.startswith("[Unreleased]"):
raise ValueError("Unexpected CHANGELOG.md format, aborting!")

return "\n\n".join(f"## {section.strip()}" for section in sections)


def main() -> None:
releases = get_releases()

release_notes_md = f"# Release Notes\n\n{releases}\n"

with RELEASE_NOTES_MD.open("w") as f:
f.write(release_notes_md)


if __name__ == "__main__":
main()

0 comments on commit ef81958

Please sign in to comment.