Make bump-version accept major/minor/patch/build.
This commit is contained in:
parent
75ec34884d
commit
f05daa8bdc
1 changed files with 34 additions and 13 deletions
|
@ -5,34 +5,51 @@ import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from lib.util import get_atom_shell_version, scoped_cwd
|
||||||
|
|
||||||
|
|
||||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2 or sys.argv[1] == '-h':
|
||||||
print 'Usage: bump-version.py version'
|
print 'Usage: bump-version.py [<version> | major | minor | patch]'
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
version = sys.argv[1]
|
option = sys.argv[1]
|
||||||
if version[0] == 'v':
|
increments = ['major', 'minor', 'patch', 'build']
|
||||||
version = version[1:]
|
if option in increments:
|
||||||
versions = parse_version(version)
|
version = get_atom_shell_version()
|
||||||
|
versions = parse_version(version.split('-')[0])
|
||||||
|
versions = increase_version(versions, increments.index(option))
|
||||||
|
else:
|
||||||
|
versions = parse_version(option)
|
||||||
|
|
||||||
os.chdir(SOURCE_ROOT)
|
version = '.'.join(versions[:3])
|
||||||
update_package_json(version)
|
|
||||||
update_win_rc(version, versions)
|
with scoped_cwd(SOURCE_ROOT):
|
||||||
update_version_h(versions)
|
update_package_json(version)
|
||||||
update_info_plist(version)
|
update_win_rc(version, versions)
|
||||||
tag_version(version)
|
update_version_h(versions)
|
||||||
|
update_info_plist(version)
|
||||||
|
tag_version(version)
|
||||||
|
git_push()
|
||||||
|
|
||||||
|
|
||||||
def parse_version(version):
|
def parse_version(version):
|
||||||
|
if version[0] == 'v':
|
||||||
|
version = version[1:]
|
||||||
|
|
||||||
vs = version.split('.')
|
vs = version.split('.')
|
||||||
if len(vs) > 4:
|
if len(vs) > 4:
|
||||||
return vs[0:4]
|
return vs[0:4]
|
||||||
else:
|
else:
|
||||||
return vs + [0] * (4 - len(vs))
|
return vs + ['0'] * (4 - len(vs))
|
||||||
|
|
||||||
|
|
||||||
|
def increase_version(versions, index):
|
||||||
|
versions[index] = str(int(versions[index]) + 1)
|
||||||
|
return versions
|
||||||
|
|
||||||
|
|
||||||
def update_package_json(version):
|
def update_package_json(version):
|
||||||
|
@ -112,5 +129,9 @@ def tag_version(version):
|
||||||
subprocess.check_call(['git', 'tag', 'v{0}'.format(version)])
|
subprocess.check_call(['git', 'tag', 'v{0}'.format(version)])
|
||||||
|
|
||||||
|
|
||||||
|
def git_push():
|
||||||
|
subprocess.check_call(['git', 'push'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
Loading…
Reference in a new issue