diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/build-scripts/create-release.py | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/build-scripts/create-release.py')
| -rwxr-xr-x | contrib/SDL-3.2.8/build-scripts/create-release.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/build-scripts/create-release.py b/contrib/SDL-3.2.8/build-scripts/create-release.py new file mode 100755 index 0000000..14916fa --- /dev/null +++ b/contrib/SDL-3.2.8/build-scripts/create-release.py | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 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()) | ||
