| 1 |
|
| 2 |
|
| 3 |
import argparse |
| 4 |
from pathlib import Path |
| 5 |
import json |
| 6 |
import logging |
| 7 |
import re |
| 8 |
import subprocess |
| 9 |
|
| 10 |
ROOT = Path(__file__).resolve().parents[1] |
| 11 |
|
| 12 |
|
| 13 |
def determine_remote() -> str: |
| 14 |
text = (ROOT / "build-scripts/release-info.json").read_text() |
| 15 |
release_info = json.loads(text) |
| 16 |
if "remote" in release_info: |
| 17 |
return release_info["remote"] |
| 18 |
project_with_version = release_info["name"] |
| 19 |
project, _ = re.subn("([^a-zA-Z_])", "", project_with_version) |
| 20 |
return f"libsdl-org/{project}" |
| 21 |
|
| 22 |
|
| 23 |
def main(): |
| 24 |
default_remote = determine_remote() |
| 25 |
|
| 26 |
parser = argparse.ArgumentParser(allow_abbrev=False) |
| 27 |
parser.add_argument("--ref", required=True, help=f"Name of branch or tag containing release.yml") |
| 28 |
parser.add_argument("--remote", "-R", default=default_remote, help=f"Remote repo (default={default_remote})") |
| 29 |
parser.add_argument("--commit", help=f"Input 'commit' of release.yml (default is the hash of the ref)") |
| 30 |
args = parser.parse_args() |
| 31 |
|
| 32 |
if args.commit is None: |
| 33 |
args.commit = subprocess.check_output(["git", "rev-parse", args.ref], cwd=ROOT, text=True).strip() |
| 34 |
|
| 35 |
|
| 36 |
print(f"Running release.yml workflow:") |
| 37 |
print(f" remote = {args.remote}") |
| 38 |
print(f" ref = {args.ref}") |
| 39 |
print(f" commit = {args.commit}") |
| 40 |
|
| 41 |
subprocess.check_call(["gh", "-R", args.remote, "workflow", "run", "release.yml", "--ref", args.ref, "-f", f"commit={args.commit}"], cwd=ROOT) |
| 42 |
|
| 43 |
|
| 44 |
if __name__ == "__main__": |
| 45 |
raise SystemExit(main()) |