forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateVersion.py
executable file
·41 lines (35 loc) · 1.3 KB
/
updateVersion.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
38
39
40
#!/usr/bin/python
import commands
import os
import sys
import time
try:
del os.environ["MACOSX_DEPLOYMENT_TARGET"]
except KeyError:
pass
from Foundation import NSMutableDictionary
if os.environ["CONFIGURATION"] == "Development":
status, output = commands.getstatusoutput("bash -l -c 'LANGUAGE=C svn info'")
if status != 0:
sys.exit(status)
for line in output.split("\n"):
if len(line.strip()) == 0 or ":" not in line:
continue
key, value = [x.lower().strip() for x in line.split(":", 1)]
if key == "revision":
revision = "svn" + value
break
elif os.environ["CONFIGURATION"] == "Nightly":
revision = time.strftime("%Y%m%d-nightly")
else:
revision = time.strftime("%Y%m%d")
buildDir = os.environ["BUILT_PRODUCTS_DIR"]
infoFile = os.environ["INFOPLIST_PATH"]
path = os.path.join(buildDir, infoFile)
plist = NSMutableDictionary.dictionaryWithContentsOfFile_(path)
version = open("version.txt").read().strip() % {"extra": revision}
print "Updating versions:", infoFile, version
plist["CFBundleShortVersionString"] = version
plist["CFBundleGetInfoString"] = version
plist["CFBundleVersion"] = version
plist.writeToFile_atomically_(path, 1)