curl https://gist.githubusercontent.com/NewFuture/4363607cebfd88df912676c7124d07b5/raw/post-commit >> .git/hooks/post-commit
Last active
March 29, 2019 12:55
-
-
Save NewFuture/4363607cebfd88df912676c7124d07b5 to your computer and use it in GitHub Desktop.
git tag package.json
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/bash | |
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/package.json | grep '^\+.*version' | sed -s 's/[^0-9\.]//g'` | |
if [ "$version" != "" ]; then | |
git tag -a "v$version" -m "`git log -1 --format=%s`" | |
echo "Created a new tag, v$version" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment