Automatically determine version from build info or git

This commit is contained in:
Matthew Wild
2021-05-31 11:14:13 +01:00
parent c6307619f9
commit 531565d55c
3 changed files with 18 additions and 6 deletions

View File

@@ -1,5 +1,15 @@
version_info = (0, 2, 1, None)
version = (
".".join(map(str, version_info[:3])) +
(f"-{version_info[3]}" if version_info[3] else "")
)
import os
import subprocess
version = "(unknown)"
if os.path.exists(".app_version"):
with open(".app_version") as f:
version = f.read().strip()
elif os.path.exists(".git"):
try:
version = subprocess.check_output([
"git", "describe", "--always"
]).strip().decode("utf8")
except OSError:
version = "dev (unknown)"