Created
June 8, 2018 20:15
-
-
Save hectorddmx/20ea78340a822583d074c0014df3f90a to your computer and use it in GitHub Desktop.
Auto increment build, version and save to Info.plist branch and commit, tested for xcode 9.4
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
echo "Setting build and version numbers..." | |
versionNumber=`date +%Y%m.%d`; echo "New versionNumber ${versionNumber}" | |
buildNumber=`date +%H%M%S`; echo "New buildNumber ${buildNumber}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $versionNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
echo "Setting branch name..." | |
function parse_git_dirty() { | |
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*" | |
} | |
# gets the current git branch | |
function parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" | |
} | |
# get last commit hash prepended with @ (i.e. @8a323d0) | |
function parse_git_hash() { | |
git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/@\1/" | |
} | |
branchName=$(parse_git_branch)$(parse_git_hash) | |
/usr/libexec/PlistBuddy -c "Set :SABranchName $branchName" "${PROJECT_DIR}/${INFOPLIST_FILE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment