-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 2.7 KB
/
publish-and-deploy.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Publish and deploy
on:
push:
branches:
- master
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: 'deploy'
cancel-in-progress: false
jobs:
lint:
name: Publish and deploy
runs-on: ubuntu-latest
steps:
# 签出分支
- uses: actions/checkout@v4
# 设置 git
- name: Setup git
run: |
git config --local user.email [email protected]
git config --local user.name AidenFEBot
# 获取tag版本
# - name: Get the version
# id: get_version
# run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# 设置node环境
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
# 设置pnpm
- uses: pnpm/action-setup@v2
with:
version: 9.4.0
# 设置 pnpm 缓存文件
- name: Cache pnpm
uses: actions/cache@v3
with:
path: |
node_modules
key: pnpm-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
# 恢复项目依赖
- name: Install
env:
# HUSKY: 0
SKIP_INSTALL_SIMPLE_GIT_HOOKS: 1
SKIP_SIMPLE_GIT_HOOKS: 1
run: |
pnpm install --frozen-lockfile
# 同步版本及推送标签
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# 更新npm版本
- name: Updated version
run: |
npm pkg set version=${{ steps.tag_version.outputs.new_version }}
git add -A
git commit -m "chore: published tag ${{ steps.tag_version.outputs.new_tag }}"
# 构建项目
- name: Run build
env:
NODE_ENV: production
run: |
pnpm build
pnpm build:doc
# 创建Github release
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
# 发布npm包
- name: Publish
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
# 推送变更至仓库
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
# 部署文档
- name: Deploy GitHub Pages site
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./docs