Created
October 9, 2013 15:23
-
-
Save ursimon/6903019 to your computer and use it in GitHub Desktop.
python script to auto-increment AndroidManifest.xml versionName + versionCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from xml.dom.minidom import parse | |
dom1 = parse("AndroidManifest.xml") | |
oldVersion = dom1.documentElement.getAttribute("android:versionName") | |
oldVersionCode = dom1.documentElement.getAttribute("android:versionCode") | |
versionNumbers = oldVersion.split('.') | |
versionNumbers[-1] = unicode(int(versionNumbers[-1]) + 1) | |
dom1.documentElement.setAttribute("android:versionName", u'.'.join(versionNumbers)) | |
dom1.documentElement.setAttribute("android:versionCode", str(int(oldVersionCode)+1)) | |
with open("AndroidManifest.xml", 'wb') as f: | |
for line in dom1.toxml("utf-8"): | |
f.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment