npm version
:
Run this in a package directory to bump the version and write the new data back to package.json [..] If run in a git repo, it will also create a version commit and tag.
How do I configure npm/ wrap npm version
command to automatically push tag to git?, i.e. an equivalent of:
npm version patch
+ [email protected]
git push origin v3.0.1
NPM documentation recommends adding a postversion
script to the prackage.json
, e.g.
"scripts": {
"postversion": "git push && git push --tags && rm -rf build/temp"
}
However, this suggestion applies to a single package only and it is bad because it syncs all the tags, not just the last created tag.
If run in a git repo, it will also create a version commit and tag. This behavior is controlled by git-tag-version (see below), and can be disabled on the command line by running npm --no-git-tag-version version .
Sharing tags is similar to pushing branches. By default, git push will not push tags. Tags have to be explicitly passed to git push . To push multiple tags simultaneously pass the --tags option to git push command.
Sharing Tags You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote branches — you can run git push origin <tagname> . If you have a lot of tags that you want to push up at once, you can also use the --tags option to the git push command.
Purpose. This NPM command allows easy incrementing in both package files and git tags, with a given tag or increment level. Run this in a package directory to bump the version and write the new data back to package.
Assuming the new tag is the only tag on the current revision something like this might work.
$ npm version patch
$ tag=$(git tag --points-at HEAD)
$ git push origin "$tag"
Otherwise you could try catching (and parsing) the output from npm version patch
like this perhaps (assuming the output is always + [email protected]
and the tag is always v<part after @
).
$ tag=$(npm version patch 2>&1)
$ tag=v${tag#*@}
$ git push origin "$tag"
You could also try grabbing the available tags before the npm version patch
call and then diffing that list against the available tags after which should find the new tag and you can push it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With