Skip to content

Commit

Permalink
Adding notes option to release script
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed May 20, 2022
1 parent 7ffddf3 commit 74915b8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions material/scripts/release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import argparse
import os
import subprocess

Expand All @@ -18,10 +19,11 @@ def get_version_from_git():
return subprocess.check_output("git tag".split()).decode().strip().split("\n")[-1]


def release(tag: str):
def release(tag: str, notes: str = ""):
"""
Release via github cli tool and show output as it occurs.
"""
# Prepare call
call = [
"gh",
"release",
Expand All @@ -32,6 +34,14 @@ def release(tag: str):
"--title",
f"Release {tag}",
]
if notes:
call.extend(["--notes", f'"{notes}"'])
# Get user confirmation
print(" ".join(call))
if not input("Continue? [y/N] ").lower().startswith("y"):
print("Aborting.")
return
# Release
with subprocess.Popen(
call,
stdout=subprocess.PIPE,
Expand All @@ -40,7 +50,6 @@ def release(tag: str):
) as p:
for line in p.stdout:
print(line, end="") # process line here

if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode, p.args)

Expand All @@ -49,6 +58,11 @@ def main():
"""
Main function.
"""
parser = argparse.ArgumentParser(description="Release a new version of gotz.")
parser.add_argument(
"--notes", "-n", help="Notes to add to the release.", default=""
)
args = parser.parse_args()
git_version = get_version_from_git()
go_version = get_version()
print("Git version: {}".format(git_version))
Expand All @@ -57,7 +71,7 @@ def main():
print("Cannot release an already released version.")
return
print(f"Releasing new version {go_version} ...")
release(go_version)
release(go_version, args.notes)


if __name__ == "__main__":
Expand Down

0 comments on commit 74915b8

Please sign in to comment.