Skip to content

Commit

Permalink
doc: Ready to geneate changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Feb 23, 2024
1 parent 0460d75 commit ded4571
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

v0.0.3
======

:date: 2024-02-24 (JST)

Features
--------

Bug fixes
---------

Miscellaneous
-------------
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ testpaths = ["tests"]
[tool.rye]
managed = true
dev-dependencies = [
"jinja2~=3.1.0",
"pytest~=8.0.1",
"sphinx~=7.2.0",
"sphinx-autobuild~=2024.2.4",
Expand Down
39 changes: 38 additions & 1 deletion tools/release-commit.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env python
"""Batch script to generate 'release' commit."""
import argparse
import shutil
import subprocess
from datetime import date
from pathlib import Path
from textwrap import dedent

import tomllib
from jinja2 import Template

root = Path(__file__).parent.parent
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -38,6 +42,39 @@ def replace_version(target, current_version: str, new_version: str):
src.write_text("\n".join(lines))


def update_changes(current_version: str, new_version: str):
"""Generate changelog for new version.
Currently, this works only generate template.
"""
CHANGELOG_TEMPLATE = Template(
dedent(
"""
v{{version}}
={{'=' * version|length}}
:date: {{now.strftime('%Y-%m-%d')}} (JST)
Features
--------
Bug fixes
---------
Miscellaneous
-------------
"""
)
)
now = date.today()
target = root / "CHANGES.rst"
move_to = root / "doc" / "changelogs" / f"v{current_version}.rst"
move_to.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(target, move_to)
target.write_text(CHANGELOG_TEMPLATE.render(version=new_version, now=now))


def main(args: argparse.Namespace):
"""Handle multi functions."""
pyproject = tomllib.loads((root / "pyproject.toml").read_text())
Expand All @@ -47,7 +84,7 @@ def main(args: argparse.Namespace):
print(f"Next version: v{new_version}")
for target in pyproject["tool"]["local"]["bumpversion"]["files"]:
replace_version(target, current_version, new_version)
pass
update_changes(current_version, new_version)


if __name__ == "__main__":
Expand Down

0 comments on commit ded4571

Please sign in to comment.