From c1a7e0e3cd61de1f97d205e2ccc128135d908314 Mon Sep 17 00:00:00 2001 From: Harsha Narayana Date: Wed, 24 Jul 2019 05:12:18 +0530 Subject: [PATCH] feat: #1631: enable change log as part of release script Signed-off-by: Harsha Narayana --- Makefile | 7 ++++--- scripts/release.py | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5b805e063e..a5af7243db 100644 --- a/Makefile +++ b/Makefile @@ -86,9 +86,10 @@ docs-test: docs-clean changelog: python scripts/changelog.py -release: changelog +release: ifdef version - python scripts/release.py --release-version ${version} + python scripts/release.py --release-version ${version} --generate-changelog else - python scripts/release.py + python scripts/release.py --generate-changelog endif + diff --git a/scripts/release.py b/scripts/release.py index c5144e91a1..fce3f751b9 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -10,6 +10,7 @@ from jinja2 import Environment, BaseLoader from requests import patch +import towncrier GIT_COMMANDS = { "get_tag": ["git describe --tags --abbrev=0"], @@ -130,7 +131,7 @@ def _get_current_tag(git_command_name="get_tag"): def _update_release_version_for_sanic( - current_version, new_version, config_file + current_version, new_version, config_file, generate_changelog ): config_parser = RawConfigParser() with open(config_file) as cfg: @@ -156,6 +157,16 @@ def _update_release_version_for_sanic( with open(config_file, "w") as config: config_parser.write(config) + if generate_changelog: + towncrier.__main( + draft=False, + directory=path.dirname(path.abspath(__file__)), + project_name=None, + project_version=new_version, + project_date=None, + answer_yes=True, + ) + command = GIT_COMMANDS.get("commit_version_change") command[0] = command[0].format( new_version=new_version, current_version=current_version @@ -253,6 +264,7 @@ def release(args: Namespace): current_version=current_version, new_version=new_version, config_file=args.config, + generate_changelog=args.generate_changelog, ) if args.tag_release: _tag_release( @@ -321,6 +333,13 @@ def release(args: Namespace): action="store_true", required=False, ) + cli.add_argument( + "--generate-changelog", + help="Generate changelog for Sanic as part of release", + default=False, + action="store_true", + required=False, + ) args = cli.parse_args() if args.tag_release: for key, value in {