Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm publish with git information instead of version from package.json

I am trying to find a solution to publish a npm artefact based on the git information.

I looked to npm version and release-it, but these tools automate git actions (commit/push) to make the link between npm artefact version and git, it doesnot get the information from git.

I would like to publish npm artefact with git identification of its source, something like the result of git describe --tags --always. Like this it could be possible to make the link between git/npm easily and the only git action is tagging, the continous integration pipeline could publish the artefact through npm publish.

git-tag-version seems making a part of the job, but doesnot makes the link with artefact version.

I will probably try to go in this way, but maybe there is some features in npm that allow to do this more easily ?

like image 331
mpromonet Avatar asked Oct 19 '25 14:10

mpromonet


1 Answers

npm version from-git seems not far from what I liked to do, except :

  • it needs a annotated tag
  • it commits the updated package.json
  • it doesnot have a different identification still the lastest tags stay the same

So finally I was using:

npm config set git-tag-version=false 
npm version $(git describe --tags)
npm publish

This doesnot commit the package json modification and allow to works with lightweight tag

like image 98
mpromonet Avatar answered Oct 21 '25 02:10

mpromonet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!