feat: #1631: enable change log as part of release script

Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
This commit is contained in:
Harsha Narayana 2019-07-24 05:12:18 +05:30
parent 80b32d0c71
commit c1a7e0e3cd
No known key found for this signature in database
GPG Key ID: 8AF211CB60D4B28C
2 changed files with 24 additions and 4 deletions

View File

@ -86,9 +86,10 @@ docs-test: docs-clean
changelog: changelog:
python scripts/changelog.py python scripts/changelog.py
release: changelog release:
ifdef version ifdef version
python scripts/release.py --release-version ${version} python scripts/release.py --release-version ${version} --generate-changelog
else else
python scripts/release.py python scripts/release.py --generate-changelog
endif endif

View File

@ -10,6 +10,7 @@ from subprocess import Popen, PIPE
from jinja2 import Environment, BaseLoader from jinja2 import Environment, BaseLoader
from requests import patch from requests import patch
import towncrier
GIT_COMMANDS = { GIT_COMMANDS = {
"get_tag": ["git describe --tags --abbrev=0"], "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( def _update_release_version_for_sanic(
current_version, new_version, config_file current_version, new_version, config_file, generate_changelog
): ):
config_parser = RawConfigParser() config_parser = RawConfigParser()
with open(config_file) as cfg: with open(config_file) as cfg:
@ -156,6 +157,16 @@ def _update_release_version_for_sanic(
with open(config_file, "w") as config: with open(config_file, "w") as config:
config_parser.write(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 = GIT_COMMANDS.get("commit_version_change")
command[0] = command[0].format( command[0] = command[0].format(
new_version=new_version, current_version=current_version new_version=new_version, current_version=current_version
@ -253,6 +264,7 @@ def release(args: Namespace):
current_version=current_version, current_version=current_version,
new_version=new_version, new_version=new_version,
config_file=args.config, config_file=args.config,
generate_changelog=args.generate_changelog,
) )
if args.tag_release: if args.tag_release:
_tag_release( _tag_release(
@ -321,6 +333,13 @@ if __name__ == "__main__":
action="store_true", action="store_true",
required=False, 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() args = cli.parse_args()
if args.tag_release: if args.tag_release:
for key, value in { for key, value in {