Skip to content

publish to npm

publish to npm #3

Workflow file for this run

name: publish to npm
on:
# 当推送到特定分支时触发,比如 `main` 分支
push:
# branches:
# - master
tags:
- v* # 匹配所有以 `v` 开头的 tag
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
# 配置 npm 的 authToken
- name: Configure npm
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
# 安装依赖
- name: Install dependencies
run: npm install
# 打包
- name: Build
run: npm run build
# 发布到 npm
- name: publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}