Last active
January 3, 2016 05:09
-
-
Save dmiedema/8413539 to your computer and use it in GitHub Desktop.
Update Xcode projects CFBuildVersion in the Info.plist based on either the last git commits sha-hash (first 6 characters) or the count of the number of git commits if on master or set production branch
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
#### | |
# XcodeBuildUpdate | |
# Created by Daniel Miedema | |
# MIT License | |
#### | |
# Variables -- change as needed | |
PROD_BRANCH="master" | |
BUILD="0" | |
CURRENT_BRANCH=$(git branch | grep "*" | cut -d ' ' -f 2) | |
COMMIT_COUNT=$(git rev-list HEAD --count) | |
COMMIT_SHA=$(git rev-list --max-count=1 HEAD | cut -c1-6) | |
if [[ $PROD_BRANCH == $CURRENT_BRANCH ]]; then | |
BUILD="$COMMIT_COUNT" | |
else | |
BUILD="$COMMIT_SHA" | |
fi | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD" "$INFOPLIST_FILE" | |
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE") | |
PATH="$SRCROOT/$PROJECT_NAME/Settings.bundle/Root.plist" | |
/usr/libexec/PlistBuddy -c "Set PreferenceSpecifiers:1:DefaultValue $VERSION" "$PATH" | |
/usr/libexec/PlistBuddy -c "Set PreferenceSpecifiers:2:DefaultValue $BUILD" "$PATH" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment