-
-
Save adamsp/da0e0bab0e25412779ff to your computer and use it in GitHub Desktop.
Script to automatically increment build number when performing a Release (archive) build on iOS
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
#!/bin/sh | |
# increment-build-number.sh | |
# Created by Adam Speakman (speakman.net.nz, @adamsnz). | |
# Script to automatically increment build number when performing a Release (archive) build on iOS | |
if [ $CONFIGURATION == Release ]; then | |
if [[ -n $(git status --porcelain) ]]; then | |
echo "Repository is dirty, commit your changes."; | |
exit 2 | |
fi | |
echo "Incrementing build number..." | |
plist=${PROJECT_DIR}/${INFOPLIST_FILE} | |
# increment the build number (ie 115 to 116) | |
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}") | |
if [[ "${buildnum}" == "" ]]; then | |
echo "No build number in $plist" | |
exit 2 | |
fi | |
buildnum=$(expr $buildnum + 1) | |
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}" | |
echo "Bumped build number to $buildnum" | |
git add ${plist} | |
git commit -m "Increment build number ($buildnum)" | |
git tag build-$buildnum | |
else | |
echo $CONFIGURATION " build - Not bumping build number." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment