From 80b32d0c7132f3c9573a11aa4f9ef223794dde77 Mon Sep 17 00:00:00 2001 From: Harsha Narayana Date: Wed, 24 Jul 2019 05:03:04 +0530 Subject: [PATCH] feat: #1631: enable make command to support settings up release Signed-off-by: Harsha Narayana --- Makefile | 24 ++++++++++++++++++++---- scripts/changelog.py | 27 ++++++++++++++++++++++----- scripts/release.py | 34 +++++++++++++++++++++++++--------- 3 files changed, 67 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 72e86aab..5b805e06 100644 --- a/Makefile +++ b/Makefile @@ -13,21 +13,27 @@ help: @echo "docker-test" @echo " Run Sanic Unit Tests using Docker" @echo "black" - @echo " Analyze and fix linting issues using Black" + @echo " Analyze and fix linting issues using Black" @echo "fix-import" @echo " Analyze and fix import order using isort" @echo "beautify [sort_imports=1] [include_tests=1]" - @echo " Analyze and fix linting issue using black and optionally fix import sort using isort" + @echo " Analyze and fix linting issue using black and optionally fix import sort using isort" @echo "" @echo "docs" - @echo " Generate Sanic documentation" + @echo " Generate Sanic documentation" @echo "" @echo "clean-docs" - @echo " Clean Sanic documentation" + @echo " Clean Sanic documentation" @echo "" @echo "docs-test" @echo " Test Sanic Documentation for errors" @echo "" + @echo "changelog" + @echo " Generate changelog for Sanic to prepare for new release" + @echo "" + @echo "release" + @echo " Prepare Sanic for a new changes by version bump and changelog" + @echo "" clean: @@ -76,3 +82,13 @@ docs: docs-clean docs-test: docs-clean cd docs && make dummy + +changelog: + python scripts/changelog.py + +release: changelog +ifdef version + python scripts/release.py --release-version ${version} +else + python scripts/release.py +endif diff --git a/scripts/changelog.py b/scripts/changelog.py index 1dc3567c..a70dbbc7 100755 --- a/scripts/changelog.py +++ b/scripts/changelog.py @@ -7,7 +7,9 @@ if __name__ == "__main__": import towncrier import click except ImportError: - print("Please make sure you have a installed towncrier and click before using this tool") + print( + "Please make sure you have a installed towncrier and click before using this tool" + ) exit(1) @click.command() @@ -16,9 +18,12 @@ if __name__ == "__main__": "draft", default=False, flag_value=True, - help="Render the news fragments, don't write to files, " "don't check versions.", + help="Render the news fragments, don't write to files, " + "don't check versions.", + ) + @click.option( + "--dir", "directory", default=path.dirname(path.abspath(__file__)) ) - @click.option("--dir", "directory", default=path.dirname(path.abspath(__file__))) @click.option("--name", "project_name", default=None) @click.option( "--version", @@ -34,9 +39,21 @@ if __name__ == "__main__": flag_value=True, help="Do not ask for confirmation to remove news fragments.", ) - def _main(draft, directory, project_name, project_version, project_date, answer_yes): + def _main( + draft, + directory, + project_name, + project_version, + project_date, + answer_yes, + ): return towncrier.__main( - draft, directory, project_name, project_version, project_date, answer_yes + draft, + directory, + project_name, + project_version, + project_date, + answer_yes, ) _main() diff --git a/scripts/release.py b/scripts/release.py index 3cc88369..c5144e91 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -254,13 +254,14 @@ def release(args: Namespace): new_version=new_version, config_file=args.config, ) - _tag_release( - current_version=current_version, - new_version=new_version, - milestone=args.milestone, - release_name=args.release_name, - token=args.token, - ) + if args.tag_release: + _tag_release( + current_version=current_version, + new_version=new_version, + milestone=args.milestone, + release_name=args.release_name, + token=args.token, + ) if __name__ == "__main__": @@ -291,13 +292,13 @@ if __name__ == "__main__": "--token", "-t", help="Git access token with necessary access to Huge Sanic Org", - required=True, + required=False, ) cli.add_argument( "--milestone", "-ms", help="Git Release milestone information to include in relase note", - required=True, + required=False, ) cli.add_argument( "--release-name", @@ -313,6 +314,21 @@ if __name__ == "__main__": action="store_true", required=False, ) + cli.add_argument( + "--tag-release", + help="Tag a new release for Sanic", + default=False, + action="store_true", + required=False, + ) args = cli.parse_args() + if args.tag_release: + for key, value in { + "--token/-t": args.token, + "--milestone/-m": args.milestone, + }.items(): + if not value: + print(f"{key} is mandatory while using --tag-release") + exit(1) with Directory(): release(args)