2019-05-24 22:14:47 +02:00
|
|
|
"""Set the build version to be 'qa', 'rc', 'release'"""
|
2018-10-22 22:31:05 +02:00
|
|
|
|
|
|
|
import sys
|
2019-05-24 22:14:47 +02:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import logging
|
|
|
|
|
|
|
|
log = logging.getLogger()
|
|
|
|
log.addHandler(logging.StreamHandler())
|
|
|
|
log.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
|
|
|
|
def get_build_type(travis_tag=None):
|
|
|
|
if not travis_tag:
|
|
|
|
return "qa"
|
|
|
|
log.debug("getting build type for tag: \"%s\"", travis_tag)
|
|
|
|
if re.match('v\d+\.\d+\.\d+rc\d+$', travis_tag):
|
|
|
|
return 'rc'
|
|
|
|
elif re.match('v\d+\.\d+\.\d+$', travis_tag):
|
|
|
|
return 'release'
|
|
|
|
return 'qa'
|
2018-10-22 22:31:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
2019-06-21 03:02:58 +02:00
|
|
|
build_type_path = os.path.join(root_dir, 'lbry', 'build_type.py')
|
2019-05-24 22:14:47 +02:00
|
|
|
log.debug("configuring build type file: %s", build_type_path)
|
|
|
|
travis_commit = os.environ['TRAVIS_COMMIT'][:6]
|
|
|
|
build_type = get_build_type(os.environ.get('TRAVIS_TAG', None))
|
|
|
|
log.debug("setting build type=%s, build commit=%s", build_type, travis_commit)
|
|
|
|
with open(build_type_path, 'w') as f:
|
|
|
|
f.write("BUILD = \"{}\"\nBUILD_COMMIT = \"{}\"\n".format(build_type, travis_commit))
|
2018-10-22 22:31:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|