improve code #7
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to npm | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # 显式赋予对内容的写权限 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # 使用更新后的v3版本 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 # 使用更新后的v4版本 | |
with: | |
node-version: '18' | |
registry-url: https://registry.npmjs.org/ | |
- name: Install dependencies | |
run: npm install | |
- name: Publish to npm | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create GitHub release | |
uses: actions/create-release@v1 # 正确使用v1版本 | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
body: | | |
Automatic release based on changes in ${{ github.ref_name }}. | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |