mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
* Have firmware version be assigned by git + Create draft release from new tag build * Fix quotes * Short commit id * Fix function call * clang-format
53 lines
1.0 KiB
Python
53 lines
1.0 KiB
Python
import subprocess
|
|
import os
|
|
|
|
revision = ""
|
|
|
|
env_rev = os.environ.get("GIT_REV")
|
|
if not env_rev is None and env_rev != "":
|
|
revision = env_rev
|
|
else:
|
|
try:
|
|
revision = (
|
|
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
|
|
.strip()
|
|
.decode("utf-8")
|
|
)
|
|
except Exception:
|
|
revision = "NOT_GIT"
|
|
|
|
tag = ""
|
|
try:
|
|
tag = (
|
|
subprocess.check_output(["git", "--no-pager", "tag", "--sort", "-taggerdate", "--points-at" , "HEAD"])
|
|
.split("\n")[0]
|
|
.strip()
|
|
.decode("utf-8")
|
|
)
|
|
|
|
if tag.startswith("v"):
|
|
tag = tag[1:]
|
|
except Exception:
|
|
tag = ""
|
|
|
|
branch = ""
|
|
try:
|
|
branch = (
|
|
subprocess.check_output(["git", "symbolic-ref", "--short", "-q", "HEAD"])
|
|
.strip()
|
|
.decode("utf-8")
|
|
)
|
|
except Exception:
|
|
branch = ""
|
|
|
|
output = f"'-DGIT_REV=\"{revision}\"'"
|
|
|
|
if tag != "":
|
|
output += f" '-DFIRMWARE_VERSION=\"{tag}\"'"
|
|
if tag == "" and branch != "":
|
|
output += f" '-DFIRMWARE_VERSION=\"{branch}\"'"
|
|
else:
|
|
output += f" '-DFIRMWARE_VERSION=\"git-{revision}\"'"
|
|
|
|
print(output)
|