chore: update publish action #4
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: Build and Publish on Main Branch | |
# 当 main 分支有 push 操作时触发 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' # 指定 Node.js 的版本 | |
- name: Install Dependencies | |
run: npm install | |
- name: Update Version | |
run: npm version patch | |
- name: Run Build | |
run: npm run build | |
- name: Run Publish | |
run: npm run pub | |
env: | |
# 设置环境变量,如需要的 API 密钥、令牌等 | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Save Version | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add package.json | |
git commit -m "Update package version" | |
git push --follow-tags |