forked from Tencent/tdesign-vue-next
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (122 loc) · 4.13 KB
/
tag-push.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# 文件名建议统一为 tag-push.yml
# 应用 publish.yml 的 demo
# name: TAG_PUSH
# on: create
# jobs:
# call-publish:
# uses: Tencent/tdesign/.github/workflows/publish.yml@main
# secrets:
# TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }}
# TDESIGN_NPM_TOKEN: ${{ secrets.TDESIGN_NPM_TOKEN }}
# PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
name: TAG_PUSH
on: create
jobs:
TAG_PUSH:
runs-on: ubuntu-latest
if: github.event.ref_type == 'tag'
steps:
# 检出代码仓库,并递归初始化子模块
- uses: actions/checkout@v4
with:
submodules: recursive
# 设置 pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v4
# 设置 Node.js 环境,版本为 18
- uses: actions/setup-node@v4
with:
node-version: 18
# 获取 pnpm 的存储目录路径
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
# 设置 pnpm 缓存
- uses: actions/cache@v4
name: Setup pnpm cache
with:
# 缓存路径
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# 缓存键
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# 恢复缓存的备用键
restore-keys: |
${{ runner.os }}-pnpm-store-
# 安装依赖
- run: pnpm i
- run: echo "🍏 This job's status is ${{ job.status }}."
- run: pnpm run build
- name: publish
id: publish
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.TDESIGN_NPM_TOKEN }}
package: packages/tdesign-vue-next
tag: ${{ contains(github.ref_name, 'beta') && 'beta' || 'latest' }}
- if: steps.publish.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
DEPLOY_HISTORY_VERSION_SITE:
runs-on: ubuntu-latest
if: github.event.ref_type == 'tag'
steps:
# 检出代码仓库,并递归初始化子模块
- uses: actions/checkout@v4
with:
submodules: recursive
# 设置 pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v4
# 设置 Node.js 环境,版本为 18
- uses: actions/setup-node@v4
with:
node-version: 18
# 获取 pnpm 的存储目录路径
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
# 设置 pnpm 缓存
- uses: actions/cache@v4
name: Setup pnpm cache
with:
# 缓存路径
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# 缓存键
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# 恢复缓存的备用键
restore-keys: |
${{ runner.os }}-pnpm-store-
# 安装依赖
- run: pnpm i
- name: Build site
run: pnpm run site:preview
- name: upload surge service
id: deploy
run: |
repository=${{github.repository}}
project_name=${repository#*/}
ref_name=${{ github.ref_name }}
tag_name=${ref_name//./_}
export DEPLOY_DOMAIN=https://$tag_name-$project_name.surge.sh
npx surge --project packages/tdesign-vue-next/site/dist --domain $DEPLOY_DOMAIN --token ${{ secrets.TDESIGN_SURGE_TOKEN }}
echo $DEPLOY_DOMAIN
UPDATE_OFFICIAL_WEBSITE:
runs-on: ubuntu-latest
if: github.event.ref_type == 'tag'
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ secrets.PERSONAL_TOKEN }}
submodules: recursive
- name: update official website
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git status
git fetch origin
git merge origin/develop
git push origin main