feat: #1631: enable make command to support settings up release

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

View File

@ -13,21 +13,27 @@ help:
@echo "docker-test" @echo "docker-test"
@echo " Run Sanic Unit Tests using Docker" @echo " Run Sanic Unit Tests using Docker"
@echo "black" @echo "black"
@echo " Analyze and fix linting issues using Black" @echo " Analyze and fix linting issues using Black"
@echo "fix-import" @echo "fix-import"
@echo " Analyze and fix import order using isort" @echo " Analyze and fix import order using isort"
@echo "beautify [sort_imports=1] [include_tests=1]" @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 ""
@echo "docs" @echo "docs"
@echo " Generate Sanic documentation" @echo " Generate Sanic documentation"
@echo "" @echo ""
@echo "clean-docs" @echo "clean-docs"
@echo " Clean Sanic documentation" @echo " Clean Sanic documentation"
@echo "" @echo ""
@echo "docs-test" @echo "docs-test"
@echo " Test Sanic Documentation for errors" @echo " Test Sanic Documentation for errors"
@echo "" @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: clean:
@ -76,3 +82,13 @@ docs: docs-clean
docs-test: docs-clean docs-test: docs-clean
cd docs && make dummy 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

View File

@ -7,7 +7,9 @@ if __name__ == "__main__":
import towncrier import towncrier
import click import click
except ImportError: 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) exit(1)
@click.command() @click.command()
@ -16,9 +18,12 @@ if __name__ == "__main__":
"draft", "draft",
default=False, default=False,
flag_value=True, 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("--name", "project_name", default=None)
@click.option( @click.option(
"--version", "--version",
@ -34,9 +39,21 @@ if __name__ == "__main__":
flag_value=True, flag_value=True,
help="Do not ask for confirmation to remove news fragments.", 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( return towncrier.__main(
draft, directory, project_name, project_version, project_date, answer_yes draft,
directory,
project_name,
project_version,
project_date,
answer_yes,
) )
_main() _main()

View File

@ -254,13 +254,14 @@ def release(args: Namespace):
new_version=new_version, new_version=new_version,
config_file=args.config, config_file=args.config,
) )
_tag_release( if args.tag_release:
current_version=current_version, _tag_release(
new_version=new_version, current_version=current_version,
milestone=args.milestone, new_version=new_version,
release_name=args.release_name, milestone=args.milestone,
token=args.token, release_name=args.release_name,
) token=args.token,
)
if __name__ == "__main__": if __name__ == "__main__":
@ -291,13 +292,13 @@ if __name__ == "__main__":
"--token", "--token",
"-t", "-t",
help="Git access token with necessary access to Huge Sanic Org", help="Git access token with necessary access to Huge Sanic Org",
required=True, required=False,
) )
cli.add_argument( cli.add_argument(
"--milestone", "--milestone",
"-ms", "-ms",
help="Git Release milestone information to include in relase note", help="Git Release milestone information to include in relase note",
required=True, required=False,
) )
cli.add_argument( cli.add_argument(
"--release-name", "--release-name",
@ -313,6 +314,21 @@ if __name__ == "__main__":
action="store_true", action="store_true",
required=False, 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() 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(): with Directory():
release(args) release(args)