-
Notifications
You must be signed in to change notification settings - Fork 184
/
version.py
executable file
·37 lines (33 loc) · 1.02 KB
/
version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# Update uProxy version in all relevant places.
#
# Run with:
# python version.py <new version>
# e.g. python version.py 0.8.10
import json
import collections
import sys
import re
manifest_files = [
'src/chrome/app/manifest.json',
'src/chrome/extension/manifest.json',
'src/firefox/package.json',
'package.json',
'bower.json',
]
if len(sys.argv) < 2:
print 'Missing version number. Usage: python version.py <new version>'
sys.exit()
else:
validVersion = re.match('[0-9]+\.[0-9]+\.[0-9]+', sys.argv[1])
if validVersion == None:
print 'Please enter a valid version number.'
sys.exit()
for filename in manifest_files:
print filename
with open(filename) as manifest:
manifest_data = json.load(manifest, object_pairs_hook=collections.OrderedDict)
manifest_data['version'] = sys.argv[1]
with open(filename, 'w') as dist_manifest:
json.dump(manifest_data, dist_manifest, indent=2, separators=(',', ': '))
dist_manifest.write('\n');