Publish to npm #29
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
# 发布到npm | |
# 开发者请在本地执行lerna version进行版本控制,提交后触发自动发布 | |
name: Publish to npm | |
on: | |
workflow_run: | |
workflows: ['Unit Tests', 'Code Check'] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
tags: | |
- 'Publish' | |
jobs: | |
build-and-publish: | |
# ['Unit Tests', 'Code Check']工作流成功完成 | |
if: > | |
github.event.workflow_run.conclusion == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # 确保检出带有版本标签的提交 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Install dependencies | |
run: yarn | |
- name: Build | |
run: yarn build | |
- name: Publish to NPM | |
run: npx lerna publish --yes from-git | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 在 GitHub Secrets 中设置的 NPM_TOKEN |