Add tool to help bump version.
This commit is contained in:
parent
d1dc041aaf
commit
e075a8b49e
2 changed files with 47 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name" : "atom-shell",
|
"name": "atom-shell",
|
||||||
"version" : "0.6.3",
|
"version": "0.6.8",
|
||||||
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coffee-script": "~1.6.3",
|
"coffee-script": "~1.6.3",
|
||||||
|
|
45
script/bump-version.py
Normal file
45
script/bump-version.py
Normal file
|
@ -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())
|
Loading…
Add table
Add a link
Reference in a new issue