Create a gist now

Instantly share code, notes, and snippets.

Script to automatically increment build number when performing a Release (archive) build on iOS
#!/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