Commit hash as version

This commit is contained in:
Gunnar Skjold 2022-01-30 11:10:30 +01:00
parent 5f0adc0f10
commit 7c1ee20e7b

View File

@ -4,8 +4,14 @@ import subprocess
FILENAME_VERSION_H = 'src/version.h'
version = os.environ.get('GITHUB_TAG')
if version == None:
result = subprocess.run(['git','rev-parse','--short','HEAD'], stdout=subprocess.PIPE)
version = result.stdout.decode('utf-8').strip()
try:
result = subprocess.run(['git','rev-parse','--short','HEAD'], capture_output=True, check=False)
if result.returncode == 0:
version = result.stdout.decode('utf-8').strip()
else:
version = "SNAPSHOT"
except:
version = "SNAPSHOT"
import datetime