-
-
Save mitchcohen/5640287 to your computer and use it in GitHub Desktop.
Xcode build phase script to set the build number to the number of commits to the git master branch, figuring the commit will be that number in the commit history (never mind the argument of the first commit being #0 or #1...)
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
# Use the number of commits on the master git branch as build number. | |
# first, confirm git exists | |
hash git 2>/dev/null || { echo >&2 "Git required, not installed. Aborting build number update script."; exit 0; } | |
VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" rev-list master | wc -l) | |
# eventually this will be (number of commits)+1. Mixed opinion here. +1 on dev machine, but not on build/distr machine. | |
# VERSION=`expr $VERSION + 1` | |
echo "Build number is now $VERSION" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSION" ${INFOPLIST_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment