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

落花浮王杯 提交于 2020-06-29 06:51:15

问题


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 ?


回答1:


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



来源:https://stackoverflow.com/questions/57380839/npm-publish-with-git-information-instead-of-version-from-package-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!