我正在使用Travis将npm模块发布到npmjs.org. .travis.yml的相关部分是: before_deploy: - npm version minor - git config credential.helper "store --file=.git/credentials" - echo "https://${GH_TOKEN}:@github.com" .git/credential
.travis.yml的相关部分是:
before_deploy: - npm version minor - git config credential.helper "store --file=.git/credentials" - echo "https://${GH_TOKEN}:@github.com" > .git/credentials - git push && git push --tags
我看到标签已创建,但对package.json的更改并未使其成为git repo.
查看travis-ci.org的日志,我看到:
$npm version minor v1.3.0 $git config credential.helper "store --file=.git/credentials" $echo "https://${GH_TOKEN}:@github.com" > .git/credentials $git push && git push --tags Everything up-to-date Counting objects: 6, done. Delta compression using up to 16 threads. Compressing objects: 25% (1/4) Compressing objects: 50% (2/4) Compressing objects: 75% (3/4) Compressing objects: 100% (4/4) Compressing objects: 100% (4/4), done. Writing objects: 25% (1/4) Writing objects: 50% (2/4) Writing objects: 75% (3/4) Writing objects: 100% (4/4) Writing objects: 100% (4/4), 411 bytes | 0 bytes/s, done. Total 4 (delta 2), reused 0 (delta 0) To https://github.com/Jellyvision/basecamp-api.git * [new tag] v1.3.0 -> v1.3.0
因此,很明显,对package.json的更改没有被添加或提交,因为推送显示所有内容都是最新的.
为了它的价值,新标签被推高了.
当我在本地运行npm版本minor时,我看到新的提交按预期生成,所以我猜这是与环境相关的,但我在文档中找不到任何暗示npm版本在CI环境中的工作方式不同的内容.
关于这里发生了什么的任何建议?
我们创建了这个publish.sh脚本,首先更新npm包版本,然后更新我们的存储库……#!/bin/sh npm version $1 git push --follow-tags npm publish
用法示例:
%> ./publish.sh 2.2.41
注意使用git push –follow-tags.这样可以更改package.json文件中的版本,使用package.json中的版本在git中创建标记版本并更新master分支.