-
Notifications
You must be signed in to change notification settings - Fork 600
41 lines (33 loc) · 1.07 KB
/
pubish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
npm version patch -m "Upgrade to %s" # 可以使用 major、minor 或 patch
git push --follow-tags
- name: Create .npmrc file
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
- name: Run Build
run: npm run build
- name: Run Publish
run: npm publish
env:
# 设置环境变量,如需要的 API 密钥、令牌等
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}