npm发布git信息,而不是package.json的版本 [英] npm publish with git information instead of version from package.json
问题描述
我试图根据git信息找到一种发布npm人工制品的解决方案.
I am trying to find a solution to publish a npm artefact based on the git information.
我查看了 npm版本和
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.
我想发布带有源代码git标识的npm人工制品,类似于git describe --tags --always
的结果.
像这样,可以轻松地在git/npm之间建立链接,并且唯一的git操作是标记,连续集成管道可以通过npm publish
发布伪像.
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 似乎已成为工作的一部分,但不会与人工制品版本建立链接.
git-tag-version seems making a part of the job, but doesnot makes the link with artefact version.
我可能会尝试以这种方式进行操作,但是npm中可能有一些功能可以更轻松地执行此操作?
I will probably try to go in this way, but maybe there is some features in npm that allow to do this more easily ?
推荐答案
npm version from-git
似乎与我喜欢做的事情相距不远,除了:
npm version from-git
seems not far from what I liked to do, except :
- 它需要带注释的标签
- 它提交更新的package.json
- 它没有不同的标识,但最新标签保持不变
所以最后我在用:
npm config set git-tag-version=false
npm version $(git describe --tags)
npm publish
这不会提交包json修改,并允许与轻量级标签一起使用
This doesnot commit the package json modification and allow to works with lightweight tag
这篇关于npm发布git信息,而不是package.json的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!