Skip to content

Instantly share code, notes, and snippets.

@olgusirman
Created February 24, 2021 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olgusirman/89249adf1a9978eeee08733fec69a6dd to your computer and use it in GitHub Desktop.
Save olgusirman/89249adf1a9978eeee08733fec69a6dd to your computer and use it in GitHub Desktop.
bumped build and version number and commit it
# 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