From a45d8c829f4a222e99e59ae1d4bebfbade6a11ba Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 24 May 2024 11:32:14 +0200 Subject: [PATCH] Fix github release script (#1492) Fixes #1467 --- utils/github-release.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/utils/github-release.py b/utils/github-release.py index 0b78a30f4..633d91f02 100644 --- a/utils/github-release.py +++ b/utils/github-release.py @@ -1,21 +1,17 @@ import subprocess -def current_git_branch(): - result = subprocess.run( - ["git", "rev-parse", "--abbrev-ref", "HEAD"], +def git_describe() -> subprocess.CompletedProcess[str]: + return subprocess.run( + ["git", "describe", "--tags", "--exact-match"], capture_output=True, text=True, - check=True, ) - return result.stdout.strip() -def main(): +def main(proc: subprocess.CompletedProcess[str]): # Get the name of the currently checked out tag - tag_name = subprocess.check_output( - ["git", "describe", "--tags", "--exact-match"], text=True - ).strip() + tag_name = proc.stdout.strip() print(f"Currently checked out tag: {tag_name}") @@ -36,7 +32,9 @@ def main(): if __name__ == "__main__": - if current_git_branch().startswith("v20"): - main() + proc = git_describe() + if proc.returncode == 0 and proc.stdout.startswith("v20"): + main(proc) else: - print("Branch doesn't start with 'v20', no release made.") + print("Current checkout is not a tag starting with 'v20', no release made.") + print(proc.stderr)