简体   繁体   English

github npm 发布失败

[英]github action for npm publish fails

Goal目标

I have manually published an open source lib to registry.npmjs.org and I want future releases to be automatically published using GitHub Actions.我已经手动将一个开源库发布到 registry.npmjs.org,我希望未来的版本能够使用 GitHub Actions 自动发布。 I have no prior experience with GitHub actions.我之前没有 GitHub 操作的经验。

What I have done so far到目前为止我做了什么

I have put the standard GitHub action into the repository which GitHub provides for that purpose ( unchanged ).我已将标准 GitHub 操作放入 GitHub 为此目的提供的存储库中(未更改)。 In its last line, it takes the automation token from npmjs.com which I have defined on the repo as environment secret NPM_TOKEN .在最后一行中,它从npmjs.com中获取自动化令牌,我在回购协议中将其定义为环境机密NPM_TOKEN It shows up in the repo's secrects page.它显示在回购协议的秘密页面中。

The error that I face我面临的错误

Run npm publish
...
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-01-08T00_20_52_834Z-debug.log
Error: Process completed with exit code 1.

Despite extensive web search, I do not understand尽管广泛搜索 web,我还是不明白

  • is there a way to verify that the automation token is picked up at all?有没有办法验证自动化令牌是否被提取?
  • why does npm publish require npm adduser , does it indicate that the automation token has not been properly picked up?为什么 npm publish 需要npm adduser ,是否表示自动化令牌没有被正确提取? After all, the action is executed on a CI node on which I couldn't npm login .毕竟,该操作是在我无法npm login的 CI 节点上执行的。 And the npm-publish.yml or its documentation shows no hint that user details need to be provided for authentication. npm-publish.yml或其文档没有显示需要提供用户详细信息以进行身份验证的提示。

I had some endeavours and got a similar problem.我做了一些努力并遇到了类似的问题。 Consider two things to look at:考虑两件事:

  1. When creating the secret token, select automation option not publish.创建秘密令牌时,select 自动化选项未发布。
  2. When adding secret to github: What I have found going to settings > secrets, there are two ways to add secrets: In the environment or to the repository.将秘密添加到 github 时:我发现转到设置 > 秘密,有两种添加秘密的方法:在环境中或在存储库中。 Adding secrets to the environment will not work.向环境添加机密将不起作用。 You need to add it as repository secret;您需要将其添加为存储库机密; please see the attached image.请看附图。快照以添加存储库秘密
  3. Confirm the secret name in secrets matches the YML file.确认 secrets 中的秘密名称与 YML 文件匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM