Skip to content

Instantly share code, notes, and snippets.

@igorcosta
Created May 23, 2016 04:32
Show Gist options
  • Save igorcosta/3754e5acc1d7f89469d39b1c293bfa61 to your computer and use it in GitHub Desktop.
Save igorcosta/3754e5acc1d7f89469d39b1c293bfa61 to your computer and use it in GitHub Desktop.
Auto increment version of npm and git tagging
#! /bin/bash
npm version patch
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/package.json | grep '^\+.*version' | sed -s 's/[^0-9\.]//g'`
git add *;
git commit -m "Commit message"
if [ "$version" != "" ]; then
git tag -a "v$version" -m "`git log -1 --format=%s`"
echo "Created a new tag, v$version"
git push --tags
npm publish
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment