Last active
December 26, 2015 09:09
-
-
Save andrewtheis/7127573 to your computer and use it in GitHub Desktop.
Grabs the latest tag and sets the version number. You must only have version numbers as tags and they must be in format "X.y[.z]-B" where: X, y are major and minor versions; z (patch version) is optional; and B is the build number. Execute this with a post-build script phase similar to this: https://gist.github.com/andrewtheis/7127566
This file contains 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 | |
PLIST_PATH="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}" | |
# Get the current version and extract the version/build from there | |
LATEST_TAG=`xcrun git describe --tags --abbrev=0` | |
TAG_BUILD_NUM=${LATEST_TAG#*-} | |
TAG_VERSION=${LATEST_TAG%-*} | |
NEW_BUILD_NUM=$(expr $TAG_BUILD_NUM + 1) | |
# Set the new version | |
defaults write "${PLIST_PATH%.*}" 'CFBundleVersion' "${NEW_BUILD_NUM}" &> /dev/null | |
BUILD_NUM_SET=`defaults read "${PLIST_PATH%.*}" 'CFBundleVersion'` | |
echo "Set build number to ${BUILD_NUM_SET} in ${INFOPLIST_PATH}" | |
# Tag it! | |
xcrun git tag ${TAG_VERSION}-${BUILD_NUM_SET} | |
xcrun git push origin --tags | |
echo "Bumped and tagged." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment