lbry-sdk/scripts/set_build.py

35 lines
951 B
Python
Raw Normal View History

2018-10-22 22:31:05 +02:00
"""Set the build version to be 'dev', 'qa', 'rc', 'release'"""
import os.path
import re
import subprocess
import sys
def main():
build = get_build()
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
with open(os.path.join(root_dir, 'lbrynet', 'build_type.py'), 'w') as f:
f.write("BUILD = '{}'\n".format(build))
def get_build():
try:
tag = subprocess.check_output(['git', 'describe', '--exact-match', '--all']).strip()
2018-10-23 04:27:57 +02:00
if re.match('tags\/v\d+\.\d+\.\d+rc\d+$', tag.decode()):
2019-02-23 03:29:09 +01:00
print('Build: rc')
2018-10-22 22:31:05 +02:00
return 'rc'
2018-10-23 04:27:57 +02:00
elif re.match('tags\/v\d+\.\d+\.\d+$', tag.decode()):
2019-02-23 03:29:09 +01:00
print('Build: release')
2018-10-22 22:31:05 +02:00
return 'release'
2019-02-23 03:29:09 +01:00
print('Build: qa')
2018-10-23 02:58:52 +02:00
return 'qa'
2018-10-22 22:31:05 +02:00
except subprocess.CalledProcessError:
2019-02-23 03:29:09 +01:00
print("Couldn't determine build type, defaulting to qa.")
2018-10-22 22:31:05 +02:00
return 'qa'
if __name__ == '__main__':
sys.exit(main())