publish to npm #5
Workflow file for this run
This file contains 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: | |
# 当推送到特定分支时触发,比如 `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 }} |