mpromonet
mpromonet

Reputation: 11942

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 ?

Upvotes: 4

Views: 2437

Answers (1)

mpromonet
mpromonet

Reputation: 11942

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

Upvotes: 7

Related Questions