Skip to content

Instantly share code, notes, and snippets.

@sgraham785
Created May 24, 2018 16:54
Show Gist options
  • Save sgraham785/81a495c13ff0bdd8048c773839d3051e to your computer and use it in GitHub Desktop.
Save sgraham785/81a495c13ff0bdd8048c773839d3051e to your computer and use it in GitHub Desktop.
auto-git-tag the npm version when publishing
{
"scripts": {
"postpublish" : "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push --tags"
}
}
Where node binary is available:
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment