Skip to content

Instantly share code, notes, and snippets.

@boboben1
Created January 9, 2019 16:03
Show Gist options
  • Save boboben1/2bce59d87d01f5c75fdff2304807a876 to your computer and use it in GitHub Desktop.
Save boboben1/2bce59d87d01f5c75fdff2304807a876 to your computer and use it in GitHub Desktop.
Automatic git tagging for NPM
#!/bin/bash; C:/Program\ Files/Git/usr/bin/sh.exe
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
# Slightly modified from: https://coderwall.com/p/mk18zq/automatic-git-version-tagging-for-npm-modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment