尝试 github 操作来自动发布 npm 包,但它显示这些错误,我不知道出了什么问题。我在代码中使用了自己的
name
和 email
,而不是所附屏幕截图中显示的虚拟数据。是的,我已经设置了秘密值NPM_PUBLISH_TOKEN
。
#.github/workflows/auto-publish.yml
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Bump version & push
run: |
git config --global user.name 'Automated publish'
git config --global user.email '[email protected]'
# Update the version in package.json, and commit & tag the change:
npm version patch # YMMV - you might want the semver level as a workflow input
git push && git push --tags
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
工作流程定义缺少一些必需的元素。请看下面。
我没有编辑 shell 脚本,因为我不确定在提交和推送之前要添加哪些特定文件。
#.github/workflows/auto-publish.yml
name: auto-publish
on:
push:
branches:
- main
- master
permissions:
contents: write
jobs:
auto-puplish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Bump version & push
run: |
git config --global user.name 'Automated publish'
git config --global user.email '[email protected]'
# Update the version in package.json, and commit & tag the change:
npm version patch # YMMV - you might want the semver level as a workflow input
git push && git push --tags
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}