From b2a6c1295cd5c8976fc078f05b992c3b8b7eb9dc Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 24 May 2019 12:43:36 -0400 Subject: [PATCH] improve set_build.py, add BUILD_COMMIT --- lbrynet/build_type.py | 1 + scripts/set_build.py | 41 ++++++++++++++++++----------------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/lbrynet/build_type.py b/lbrynet/build_type.py index 862548fbc..07a818289 100644 --- a/lbrynet/build_type.py +++ b/lbrynet/build_type.py @@ -1,2 +1,3 @@ # don't touch this. CI server changes this during build/deployment BUILD = "dev" +BUILD_COMMIT = "source installation" diff --git a/scripts/set_build.py b/scripts/set_build.py index f4b4d4253..29e6c8a1a 100644 --- a/scripts/set_build.py +++ b/scripts/set_build.py @@ -1,33 +1,28 @@ +"""Set the build version to be 'qa', 'rc', 'release'""" -"""Set the build version to be 'dev', 'qa', 'rc', 'release'""" - -import os.path -import re -import subprocess import sys +import os +import re + + +def get_build_type(travis_tag=None): + if not travis_tag: + return "qa" + print("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' def main(): - build = get_build() root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + travis_commit = os.environ['TRAVIS_COMMIT'][:6] + build_type = get_build_type(os.environ.get('TRAVIS_TAG', None)) + print("setting build type=%s, build commit=%s", build_type, travis_commit) 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() - if re.match('tags\/v\d+\.\d+\.\d+rc\d+$', tag.decode()): - print('Build: rc') - return 'rc' - elif re.match('tags\/v\d+\.\d+\.\d+$', tag.decode()): - print('Build: release') - return 'release' - print('Build: qa') - return 'qa' - except subprocess.CalledProcessError: - print("Couldn't determine build type, defaulting to qa.") - return 'qa' + f.write("BUILD = \"{}\"\nBUILD_COMMIT = \"{}\"\n".format(build_type, travis_commit)) if __name__ == '__main__':