Skip to content

Instantly share code, notes, and snippets.

@everm1nd
Created March 22, 2018 11:08
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 everm1nd/50bc8e92911dec5d4fa2d609a6493be4 to your computer and use it in GitHub Desktop.
Save everm1nd/50bc8e92911dec5d4fa2d609a6493be4 to your computer and use it in GitHub Desktop.
Tag New Package Release on Travis Build
#!/bin/bash
# This script will create a git-tag if version in package.json changes
git config --global user.email "builds@travis-ci.com"
git config --global user.name "Travis CI"
VERSION=$(node -pe "require('./package.json').version")
export PACKAGE_VERSION="v${VERSION}"
export LAST_TAG=$(git tag --sort version:refname | tail -1)
echo "Package version is:" $PACKAGE_VERSION
echo "Last tag is:" $LAST_TAG
if [ $PACKAGE_VERSION != $LAST_TAG ]
then
echo Tagging release...
git tag $PACKAGE_VERSION -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
git push --tags
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment