Skip to content

Commit

Permalink
feat: sanic-org#1631: enable change log as part of release script
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Narayana <[email protected]>
  • Loading branch information
harshanarayana committed Jul 24, 2019
1 parent 80b32d0 commit c1a7e0e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

21 changes: 20 additions & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from jinja2 import Environment, BaseLoader
from requests import patch
import towncrier

GIT_COMMANDS = {
"get_tag": ["git describe --tags --abbrev=0"],
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c1a7e0e

Please sign in to comment.