Skip to content

Workflow file for this run

# This workflow will run build using node and then publish a package to npm when a release is published
# 此工作流程将使用node运行构建,然后在release版本发布完成时将包发布到 npm
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Publish node.js package to npm
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: esm # 上传的包名,通过上传下载来传递打包后的资源
path: ./esm # 将构建输出的目录上传
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: esm # 下载的包名
path: ./esm # 将esm包下载到./esm目录一起发布
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}