一.关闭发布包时的两步验证
如果没有开启两步验证直接看下一步
前往https://www.npmjs.com/settings/yourname/tfa/list
取消勾选Require two-factor authentication for write actions
然后点击Update Preferences
更新设置
二、去npm管理后台创建AccessTokens:
前往https://www.npmjs.com/settings/yourname/tokens 新建一个Classic Token
Token类型选择 publish
三、前往github项目设置页将上一步生成的token添加到Repository secrets中
在Repository secrets中创建一个名为NPM_TOKEN
的secrets
四、点击Actions选项卡 搜索Publish Node.js Package并创建
五、编辑 .github/workflows/npm-publish.yml文件并提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages name: npm-publish on: release: types: [created] jobs: publish-npm: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: node-version: 20 registry-url: https://registry.npmjs.org/ - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
六、前往Code选项卡创建一个release来触发publish-npm
文章评论 暂无评论
暂无评论