-
-
Save karlvr/c93a98d7000ecb163895 to your computer and use it in GitHub Desktop.
Revisions
-
karlvr revised this gist
May 8, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -72,6 +72,6 @@ echo "MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT" echo "BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT" echo "BUNDLE_VERSION: $BUNDLE_VERSION" /usr/libexec/PlistBuddy -c "Add :CFBundleBuildVersion string $BUILD_VERSION" "$INFO_PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleBuildVersion $BUILD_VERSION" "$INFO_PLIST" /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $SHORT_VERSION" "$INFO_PLIST" /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUNDLE_VERSION" "$INFO_PLIST" -
karlvr revised this gist
May 8, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -72,6 +72,6 @@ echo "MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT" echo "BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT" echo "BUNDLE_VERSION: $BUNDLE_VERSION" /usr/libexec/PlistBuddy -c "Add :CFBundleBuildVersion string $BUILD_VERSION" "$INFO_PLIST" || /usr/libexec/PlistBuddy -c "Set :CFBundleBuildVersion $BUILD_VERSION" "$INFO_PLIST" /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $SHORT_VERSION" "$INFO_PLIST" /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUNDLE_VERSION" "$INFO_PLIST" -
karlvr revised this gist
May 8, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ BUILD_VERSION=$(git describe --tags --always --dirty=+) # Use the latest tag for short version (expected tag format "vn[.n[.n]]") # or if there are no tags, we make up version 0.0.<commit count> LATEST_TAG=$(git describe --tags --match 'v*' --abbrev=0 2>/dev/null) || LATEST_TAG="HEAD" if [ $LATEST_TAG = "HEAD" ] then COMMIT_COUNT=$(git rev-list --count HEAD) LATEST_TAG="0.0.$COMMIT_COUNT" -
karlvr revised this gist
May 8, 2014 . 1 changed file with 40 additions and 35 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -22,51 +22,56 @@ INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" # Build version (closest-tag-or-branch "-" commits-since-tag "-" short-hash dirty-flag) BUILD_VERSION=$(git describe --tags --always --dirty=+) # Use the latest tag for short version (expected tag format "vn[.n[.n]]") # or if there are no tags, we make up version 0.0.<commit count> LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null) || LATEST_TAG="HEAD" if [ $LATEST_TAG = "HEAD" ] then COMMIT_COUNT=$(git rev-list --count HEAD) LATEST_TAG="0.0.$COMMIT_COUNT" COMMIT_COUNT_SINCE_TAG=0 else COMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..) LATEST_TAG=${LATEST_TAG##v} # Remove the "v" from the front of the tag fi if [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then SHORT_VERSION="$LATEST_TAG" else # increment final digit of tag and append "d" + commit-count-since-tag # e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1 # this is the bit that requires /bin/bash OLD_IFS=$IFS IFS="." VERSION_PARTS=($LATEST_TAG) LAST_PART=$((${#VERSION_PARTS[@]}-1)) VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1)) SHORT_VERSION="${VERSION_PARTS[*]}d${COMMIT_COUNT_SINCE_TAG}" IFS=$OLD_IFS fi # Bundle version (commits-on-master[-until-branch "." commits-on-branch]) # Assumes that two release branches will not diverge from the same commit on master. if [ $(git rev-parse --abbrev-ref HEAD) = "master" ]; then MASTER_COMMIT_COUNT=$(git rev-list --count HEAD) BRANCH_COMMIT_COUNT=0 BUNDLE_VERSION="$MASTER_COMMIT_COUNT" else MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^) BRANCH_COMMIT_COUNT=$(git rev-list --count master..) if [ $BRANCH_COMMIT_COUNT = 0 ] then BUNDLE_VERSION="$MASTER_COMMIT_COUNT" else BUNDLE_VERSION="${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}" fi fi # For debugging: echo "BUILD VERSION: $BUILD_VERSION" echo "LATEST_TAG: $LATEST_TAG" echo "COMMIT_COUNT_SINCE_TAG: $COMMIT_COUNT_SINCE_TAG" echo "SHORT VERSION: $SHORT_VERSION" echo "MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT" echo "BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT" echo "BUNDLE_VERSION: $BUNDLE_VERSION" /usr/libexec/PlistBuddy -c "Add :CFBundleBuildVersion string $BUILD_VERSION" "$INFOPLIST_FILE" || /usr/libexec/PlistBuddy -c "Set :CFBundleBuildVersion $BUILD_VERSION" "$INFOPLIST_FILE" /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $SHORT_VERSION" "$INFOPLIST_FILE" /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUNDLE_VERSION" "$INFOPLIST_FILE" -
nickshanks revised this gist
Feb 19, 2014 . 1 changed file with 15 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/bin/bash # This script automatically sets the version and short version string of # an Xcode project from the Git repository containing the project. @@ -28,12 +28,22 @@ COMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..) if [ $LATEST_TAG = "start" ] then LATEST_TAG=0 fi if [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then SHORT_VERSION="$LATEST_TAG" else # increment final digit of tag and append "d" + commit-count-since-tag # e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1 # this is the bit that requires /bin/bash OLD_IFS=$IFS IFS="." VERSION_PARTS=($LATEST_TAG) LAST_PART=$((${#VERSION_PARTS[@]}-1)) VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1)) SHORT_VERSION="${VERSION_PARTS[*]}d${COMMIT_COUNT_SINCE_TAG}" IFS=$OLD_IFS fi # Bundle version (commits-on-master[-until-branch "." commits-on-branch]) # Assumes that two release branches will not diverge from the same commit on master. if [ $(git rev-parse --abbrev-ref HEAD) = "master" ]; then MASTER_COMMIT_COUNT=$(git rev-list --count HEAD) -
nickshanks revised this gist
Feb 17, 2014 . 1 changed file with 49 additions and 15 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,28 +1,62 @@ #!/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, add the script's path to a "Run Script" build # phase for your application target. set -o errexit set -o nounset # First, check for git in $PATH hash git 2>/dev/null || { echo >&2 "Git required, not installed. Aborting build number update script."; exit 0; } # Alternatively, we could use Xcode's copy of the Git binary, # but old Xcodes don't have this. #GIT=$(xcrun -find git) # Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use “BUILT_PRODUCTS_DIR” instead. INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" # Build version (closest-tag-or-branch "-" commits-since-tag "-" short-hash dirty-flag) BUILD_VERSION=$(git describe --tags --always --dirty=+) # Use the latest tag for short version (expected tag format "n[.n[.n]]") LATEST_TAG=$(git describe --tags --abbrev=0) COMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..) if [ $LATEST_TAG = "start" ] then LATEST_TAG=0 fi if [ $COMMIT_COUNT_SINCE_TAG = 0 ] then SHORT_VERSION="$LATEST_TAG" else SHORT_VERSION="${LATEST_TAG}d${COMMIT_COUNT_SINCE_TAG}" fi # Bundle version (commits-on-master-until-branch "." commits-on-branch) # Assumes that two release branches will not diverge from the same commit on master. if [ $(git rev-parse --abbrev-ref HEAD) = "master" ]; then MASTER_COMMIT_COUNT=$(git rev-list --count HEAD) BRANCH_COMMIT_COUNT=0 BUNDLE_VERSION="$MASTER_COMMIT_COUNT" else MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^) BRANCH_COMMIT_COUNT=$(git rev-list --count master..) if [ $BRANCH_COMMIT_COUNT = 0 ] then BUNDLE_VERSION="$MASTER_COMMIT_COUNT" else BUNDLE_VERSION="${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}" fi fi defaults write "$INFO_PLIST" CFBundleBuildVersion "$BUILD_VERSION" defaults write "$INFO_PLIST" CFBundleShortVersionString "$SHORT_VERSION" defaults write "$INFO_PLIST" CFBundleVersion "$BUNDLE_VERSION" # For debugging: #echo "BUILD VERSION: $BUILD_VERSION" #echo "LATEST_TAG: $LATEST_TAG" #echo "COMMIT_COUNT_SINCE_TAG: $COMMIT_COUNT_SINCE_TAG" #echo "SHORT VERSION: $SHORT_VERSION" #echo "MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT" #echo "BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT" #echo "BUNDLE_VERSION: $BUNDLE_VERSION" -
jpwatts revised this gist
May 13, 2011 . 1 changed file with 12 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,19 +3,26 @@ # 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 v0.0.0; this assumes you're doing the same. SHORT_VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" describe --dirty | sed -e 's/^v//' -e 's/g//') # I'd like to use the Git commit hash for CFBundleVersion. # VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" rev-parse --short HEAD) # But Apple wants this value to be a monotonically increasing integer, so # instead use the number of commits on the master branch. If you like to # play fast and loose with your Git history, this may cause you problems. # Thanks to @amrox for pointing out the issue and fix. VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" rev-list master | wc -l) defaults write $INFO_PLIST CFBundleShortVersionString $SHORT_VERSION defaults write $INFO_PLIST CFBundleVersion $VERSION -
jpwatts created this gist
May 11, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/bin/bash # This script automatically sets the version and short version string of # an Xcode project from the Git repository containing the project. # # I tag releases in Git using the format v0.0[.0] and this script assumes # you're doing the same. If you're using a different tag format, you'll # need to adjust how $SHORT_VERSION is created. # # 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" SHORT_VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" describe --dirty | sed -e 's/^v//' -e 's/g//') VERSION=$(git --git-dir="${PROJECT_DIR}/.git" --work-tree="${PROJECT_DIR}" rev-parse --short HEAD) defaults write $INFO_PLIST CFBundleShortVersionString $SHORT_VERSION defaults write $INFO_PLIST CFBundleVersion $VERSION