Last active
December 15, 2015 03:49
-
-
Save jourdein/5196772 to your computer and use it in GitHub Desktop.
Build number based on Git revision and incremented build number (the last number). The number separated by decimal. i.e. 121.5432
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
#!/bin/bash | |
git=/usr/local/git/bin/git | |
touch "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
gitBuildNumber=`$git log --oneline | wc -l` | |
echo "#define BUILD_VERSION $gitBuildNumber" > NST/NST-InfoPlist.h | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}") | |
majorVersion=$gitBuildNumber | |
#`echo "scale=0; $buildNumber / 1" | bc` | |
floatingPartAsInteger=`echo "$buildNumber % 1" | bc` | |
multiplication=`echo "10^length($floatingPartAsInteger)" | bc` | |
incrementedBuildNumber=`echo "($floatingPartAsInteger * $multiplication / 1) + 1" | bc` | |
buildNumber=`echo "scale=length($incrementedBuildNumber); $majorVersion + ($incrementedBuildNumber / 10^length($incrementedBuildNumber))" | bc` | |
# http://semver.org/ | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment