Skip to content

Instantly share code, notes, and snippets.

@mderazon
Last active August 29, 2015 14:23
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 mderazon/3385291c38cad22896b5 to your computer and use it in GitHub Desktop.
Save mderazon/3385291c38cad22896b5 to your computer and use it in GitHub Desktop.
automatically create a tag for package version bump
# file: .git/config
# this pushes every branch that's already there, plus tags. It does not force push, and it does not push branch that we didn't push manually.
[remote "origin"] # or whatever it is named
url = ...
push = :
push = +refs/tags/*:refs/tags/*
#! /bin/bash
# file: .git/hooks/post-commit
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/package.json | grep '^\+.*version' | sed '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
@mderazon
Copy link
Author

  • post-commit - each time there's a version update in package.json it creates a tag with the new version number
  • config - automatically pushes the tag along the commit to gh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment