Include git hash in version

pull/31/head
Łukasz Nidecki 2 years ago
parent 97c9afef4a
commit 82ca1c2061

@ -3,6 +3,7 @@ FILENAME_VERSION_H = 'include/version.h'
version = 'v0.3.'
import datetime
from subprocess import *
build_no = 0
try:
@ -15,7 +16,15 @@ with open(FILENAME_BUILDNO, 'w+') as f:
f.write(str(build_no))
print('Build number: {}'.format(build_no))
version_string = "{} - {}".format(version+str(build_no), datetime.datetime.now())
version_full = version + str(build_no)
try:
git_id = Popen('git rev-parse --short HEAD', stdout=PIPE, shell=True).stdout.read().strip().decode('ascii')
version_full = "%s-%s" % (version_full, git_id)
except:
pass
version_string = "{} - {}".format(version_full, datetime.datetime.now())
hf = """
#ifndef BUILD_NUMBER
#define BUILD_NUMBER "{}"
@ -26,7 +35,7 @@ hf = """
#ifndef VERSION_SHORT
#define VERSION_SHORT "{}"
#endif
""".format(build_no, version_string, version+str(build_no))
""".format(build_no, version_string, version_full)
with open(FILENAME_VERSION_H, 'w+') as f:
f.write(hf)

Loading…
Cancel
Save