-
-
Save naiveal/3235539 to your computer and use it in GitHub Desktop.
Automated Xcode build script to update CFBundleVersion, commit and tag with Git.
This file contains hidden or 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 AppKit import NSMutableDictionary | |
import os | |
# Get the name of the current configuration. | |
configuration = os.environ['CONFIGURATION'] | |
# List of valid configurations where this script should run. | |
configurations_list = ['Beta', 'App Store'] | |
if configuration in configurations_list: | |
# Get the name of the info.plist file. | |
infoplist_file = os.environ['INFOPLIST_FILE'] | |
# Load it into a mutable dictionary and update it. | |
info_dictionary = NSMutableDictionary.dictionaryWithContentsOfFile_(infoplist_file) | |
bundle_version = int(info_dictionary['CFBundleVersion']) + 1 | |
version_string = str(bundle_version) | |
info_dictionary['CFBundleVersion'] = version_string | |
# Write back the updated file. | |
info_dictionary.writeToFile_atomically_(infoplist_file, True) | |
# Commit the current build using Git. | |
os.system('git commit -am "Automated Commit For Build ' + version_string + '. Configuration: ' + configuration + '."') | |
# Tag the build with the configuration name and build number. | |
# Format the configuration name to replace characters that will cause tagging to fail. | |
formatted_configuration = configuration.replace(' ', '').replace('-', '') | |
os.system('git tag ' + formatted_configuration + '_' + version_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment