Seed Support #56

Closed
ocnios wants to merge 173 commits from master into build
2 changed files with 10 additions and 82 deletions
Showing only changes of commit 10580729f8 - Show all commits

View file

@ -1,41 +0,0 @@
"""Set the build version to be 'dev', 'qa', 'rc', 'release'"""
from __future__ import print_function
import os.path
import re
import subprocess
import sys
import fileinput
def main():
build = get_build()
with open(os.path.join('lbry', 'lbrynet', 'build_type.py'), 'w') as f:
f.write('BUILD = "{}"'.format(build))
set_early_access()
def set_early_access():
filename = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..', 'ui', 'js', 'lbryio.js'))
for line in fileinput.input(filename, inplace=True):
if line.startswith(' enabled: false'):
print(' enabled: true')
else:
print(line, end='')
def get_build():
try:
tag = subprocess.check_output(['git', 'describe', '--exact-match']).strip()
if re.match('v\d+\.\d+\.\d+rc\d+', tag):
return 'rc'
else:
return 'release'
except subprocess.CalledProcessError:
# if the build doesn't have a tag
return 'qa'
if __name__ == '__main__':
sys.exit(main())

View file

@ -1,51 +1,20 @@
"""Set the package version to the output of `git describe`"""
import argparse
import json
from __future__ import print_function
import os.path
import re
import subprocess
import sys
import fileinput
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--version', help="defaults to the output of `git describe`")
args = parser.parse_args()
if args.version:
version = args.version
else:
tag = subprocess.check_output(['git', 'describe']).strip()
try:
version = get_version_from_tag(tag)
except InvalidVersionTag:
# this should be an error but its easier to handle here
# than in the calling scripts.
print 'Tag cannot be converted to a version, Exitting'
return
set_version(version)
class InvalidVersionTag(Exception):
pass
def get_version_from_tag(tag):
match = re.match('v([\d.]+)', tag)
if match:
return match.group(1)
else:
raise InvalidVersionTag('Failed to parse version from tag {}'.format(tag))
def set_version(version):
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
package_file = os.path.join(root_dir, 'app', 'package.json')
with open(package_file) as fp:
package_data = json.load(fp)
package_data['version'] = version
with open(package_file, 'w') as fp:
json.dump(package_data, fp, indent=2, separators=(',', ': '))
filename = os.path.abspath(
os.path.join(os.path.abspath(__file__), '..', '..', 'ui', 'js', 'lbryio.js'))
for line in fileinput.input(filename, inplace=True):
if line.startswith(' enabled: false'):
print(' enabled: true')
else:
print(line, end='')
if __name__ == '__main__':