From: Cheng Zhao Date: Thu, 7 Nov 2013 04:52:26 +0000 (+0800) Subject: Add tool to help bump version. X-Git-Tag: v0.6.9~8 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e075a8b49e1eb692d028c07a46e0d7513628b72a;p=electron.git Add tool to help bump version. --- diff --git a/package.json b/package.json index f1dac6e9..0084f619 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name" : "atom-shell", - "version" : "0.6.3", + "name": "atom-shell", + "version": "0.6.8", "devDependencies": { "coffee-script": "~1.6.3", diff --git a/script/bump-version.py b/script/bump-version.py new file mode 100644 index 00000000..7ba2f615 --- /dev/null +++ b/script/bump-version.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import os +import re +import subprocess +import sys + + +def main(): + if len(sys.argv) != 2: + print 'Usage: bump-version.py version' + return 1 + + version = sys.argv[1] + if version[0] == 'v': + version = version[1:] + versions = parse_version(version) + + os.chdir(os.path.dirname(os.path.dirname(__file__))) + update_package_json(version) + + +def parse_version(version): + vs = version.split('.') + if len(vs) > 4: + return vs[0:4] + else: + return vs + [0] * (4 - len(vs)) + + +def update_package_json(version): + pattern = re.compile(' *"version" *: *"[0-9.]+"') + with open('package.json', 'r') as f: + lines = f.readlines() + + for i in range(0, len(lines)): + if pattern.match(lines[i]): + lines[i] = ' "version": "{0}",\n'.format(version) + with open('package.json', 'w') as f: + f.write(''.join(lines)) + return + + +if __name__ == '__main__': + sys.exit(main())