Skip to content

Commit

Permalink
feat: sanic-org#1631: enable make command to support settings up release
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Narayana <[email protected]>
  • Loading branch information
harshanarayana committed Jul 23, 2019
1 parent 3842eb3 commit 80b32d0
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
27 changes: 22 additions & 5 deletions scripts/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
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()
Expand All @@ -16,9 +18,12 @@
"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",
Expand All @@ -34,9 +39,21 @@
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()
34 changes: 25 additions & 9 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down Expand Up @@ -291,13 +292,13 @@ def release(args: Namespace):
"--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",
Expand All @@ -313,6 +314,21 @@ def release(args: Namespace):
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)

0 comments on commit 80b32d0

Please sign in to comment.