Skip to content

Instantly share code, notes, and snippets.

@NewFuture
Last active March 29, 2019 12:55
Show Gist options
  • Save NewFuture/4363607cebfd88df912676c7124d07b5 to your computer and use it in GitHub Desktop.
Save NewFuture/4363607cebfd88df912676c7124d07b5 to your computer and use it in GitHub Desktop.
git tag package.json
curl https://gist.githubusercontent.com/NewFuture/4363607cebfd88df912676c7124d07b5/raw/post-commit >> .git/hooks/post-commit
#! /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