Created
November 26, 2020 12:26
-
-
Save olgusirman/7e80156b7677131e7b899f6bf17f44e7 to your computer and use it in GitHub Desktop.
This script gets the version and build number and automatically updates, set tag and commit
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
# Find the current marketing version | |
OLD_VERSION=$(agvtool what-marketing-version -terse1) | |
# Get the current marketing version values | |
##replace . with space so can split into an array | |
VERSION_BITS=(${OLD_VERSION//./ }) | |
##get tag number parts for version and build numbers | |
VNUM1=${VERSION_BITS[0]} | |
VNUM2=${VERSION_BITS[1]} | |
VNUM3=${VERSION_BITS[2]} | |
# Bump the current marketing version third value | |
### Increment version numer | |
VNUM3=$((VNUM3+1)) | |
# bump version number | |
xcrun agvtool new-marketing-version $VNUM1.$VNUM2.$VNUM3 | |
# bump the build number | |
agvtool next-version -all | |
# Get the new build number | |
NEW_BUILD_NUMBER=$(agvtool what-version -terse) | |
# Set version and build number as a tag | |
## create new tag | |
NEW_TAG="v$VNUM1.$VNUM2.$VNUM3($NEW_BUILD_NUMBER)" | |
# add and push that commit | |
git add . | |
git commit -m "Bump version and build number to $NEW_TAG" | |
git push | |
echo "Updating version to $NEW_TAG" | |
#get current hash and see if it already has a tag | |
GIT_COMMIT=`git rev-parse HEAD` | |
NEEDS_TAG=`git describe --contains $GIT_COMMIT 2>/dev/null` | |
#only tag if no tag already | |
if [ -z "$NEEDS_TAG" ]; then | |
git tag -a $NEW_TAG -m "$TAG_DESCRIPTION" | |
echo "Tagged with $NEW_TAG" | |
git push --tags | |
else | |
echo "Already a tag on this commit" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment