Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save danieltorrecillas/2ed0b957d225ef7cc9d82b2f0a1e4bb4 to your computer and use it in GitHub Desktop.
Save danieltorrecillas/2ed0b957d225ef7cc9d82b2f0a1e4bb4 to your computer and use it in GitHub Desktop.
Increment CFBundleVersion (build) number from git
git=`sh /etc/profile; which git`
branch_name=`$git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,'`
git_count=`$git rev-list $branch_name |wc -l | sed 's/^ *//;s/ *$//'`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $git_count" "${PRODUCT_SETTINGS_PATH}"
echo "Updated build number in ${PRODUCT_SETTINGS_PATH} to $git_count from $branch_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment