aboutsummaryrefslogtreecommitdiff
path: root/publish/get_version.py
blob: 0c19c2de23d1eb23fdf73ee0a21babaa275094d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import subprocess
import sys
import os

ver = None

versionPath = os.path.dirname(sys.argv[0]) + "/version.txt"
if os.path.exists(versionPath):
    with open(versionPath, "r", encoding="utf8") as fp:
        ver = fp.read()
else:
    ver = subprocess.run("git describe --tags --dirty", capture_output=True, text=True).stdout or "UNKNOWN-" + subprocess.run("git describe --always --dirty", capture_output=True, text=True).stdout or "UNKNOWN"

print(ver.strip())