sdl2-compat: create-release.py: use head of git ref as default commit

From 79e7d6e316876056b88b2931fb2d9bc30bcf61f0 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 2 Nov 2024 04:29:33 +0100
Subject: [PATCH] create-release.py: use head of git ref as default commit

[ci skip]
---
 build-scripts/build-release.py  |  2 +-
 build-scripts/create-release.py | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/build-scripts/build-release.py b/build-scripts/build-release.py
index 5ef2a34..3295c1f 100755
--- a/build-scripts/build-release.py
+++ b/build-scripts/build-release.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """
 This script is shared between SDL2, SDL3, and all satellite libraries.
diff --git a/build-scripts/create-release.py b/build-scripts/create-release.py
index 8ab367a..14916fa 100755
--- a/build-scripts/create-release.py
+++ b/build-scripts/create-release.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import argparse
 from pathlib import Path
@@ -23,18 +23,20 @@ def determine_remote() -> str:
 def main():
     default_remote = determine_remote()
 
-    current_commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip()
-
     parser = argparse.ArgumentParser(allow_abbrev=False)
     parser.add_argument("--ref", required=True, help=f"Name of branch or tag containing release.yml")
     parser.add_argument("--remote", "-R", default=default_remote, help=f"Remote repo (default={default_remote})")
-    parser.add_argument("--commit", default=current_commit, help=f"Commit (default={current_commit})")
+    parser.add_argument("--commit", help=f"Input 'commit' of release.yml (default is the hash of the ref)")
     args = parser.parse_args()
 
+    if args.commit is None:
+        args.commit = subprocess.check_output(["git", "rev-parse", args.ref], cwd=ROOT, text=True).strip()
+
 
     print(f"Running release.yml workflow:")
-    print(f"  commit = {args.commit}")
     print(f"  remote = {args.remote}")
+    print(f"     ref = {args.ref}")
+    print(f"  commit = {args.commit}")
 
     subprocess.check_call(["gh", "-R", args.remote, "workflow", "run", "release.yml", "--ref", args.ref, "-f", f"commit={args.commit}"], cwd=ROOT)