lbry-desktop/set_version.py

37 lines
994 B
Python
Raw Normal View History

2017-02-10 03:09:31 +01:00
"""Set the package version to the output of `git describe`"""
2017-02-16 19:19:35 +01:00
import argparse
2017-02-10 03:09:31 +01:00
import json
import os.path
import subprocess
import sys
def main():
2017-02-16 19:19:35 +01:00
parser = argparse.ArgumentParser()
parser.add_argument('--version', help="defaults to the output of `git describe`")
args = parser.parse_args()
version = args.version or subprocess.check_output(['git', 'describe']).strip()
set_version(version)
def set_version(version):
2017-02-10 03:09:31 +01:00
package_file = os.path.join('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=(',', ': '))
2017-02-16 19:19:35 +01:00
with open(os.path.join('lbry', 'lbrynet', '__init__.py'), 'w') as fp:
fp.write(LBRYNET_TEMPLATE.format(version=version))
LBRYNET_TEMPLATE = """
__version__ = "{version}"
version = tuple(__version__.split('.'))
"""
2017-02-10 03:09:31 +01:00
if __name__ == '__main__':
sys.exit(main())