Created
August 10, 2013 09:11
-
-
Save stig/6199708 to your computer and use it in GitHub Desktop.
Short script to set CFBundleShortVersionString from the latest tag + CFBundleVersion from the number of commits on the master branch. It is useful to use with Jenkins, and doesn't require you to update the repository, so you don't pollute your change history with "updated version" commits.
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/sh | |
# This script automatically sets the version and short version string of an | |
# Xcode project from the Git repository containing the project. | |
# | |
# To use this script in Xcode 4, add the contents to a "Run Script" build | |
# phase for your application target. | |
set -o errexit | |
set -o nounset | |
INFO_PLIST="${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/Info" | |
# Use the latest version tag for CFBundleShortVersionString. I tag releases | |
# in Git using the format 0.0.0; this assumes you're doing the same. | |
MARKETING_VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" describe --abbrev=0) | |
# Apple wants CFBundleVersion to be a monotonically increasing integer, so | |
# use the number of commits on master. | |
VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" rev-list master | wc -l) | |
defaults write $INFO_PLIST CFBundleShortVersionString $MARKETING_VERSION | |
defaults write $INFO_PLIST CFBundleVersion $VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment