-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
214 lines (208 loc) · 7.02 KB
/
.gitlab-ci.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
stages:
- build
- sync
build:yarn:node:18.16.0:
stage: build
# 使用作者构建的镜像,无需运行 apt-get update && apt-get install -y rpm,节省时间,避免网络影响
image: xuxiaoweicomcn/node-rpm:18.16.0
variables:
# yarn 缓存路径
YARN_CACHE_FOLDER: $CI_PROJECT_DIR/.cache
# electron 缓存路径
ELECTRON_CACHE: $CI_PROJECT_DIR/.cache/electron/cache
# electron-builder 缓存路径
ELECTRON_BUILDER_CACHE: $CI_PROJECT_DIR/.cache/electron-builder/cache
script:
- yarn config set registry https://registry.npmmirror.com
- yarn install
# 使用作者构建的镜像,无需运行 apt-get update && apt-get install -y rpm,即可构建 .rpm 产物,节省时间,避免网络影响
# - apt-get update
# - apt-get install -y rpm
- cat electron-builder.json5
# 增加 .rpm 产物
- sed -i '/"AppImage",/i \ \ \ \ \ \ "rpm",' electron-builder.json5
# 增加 .deb 产物
- sed -i '/"AppImage",/i \ \ \ \ \ \ "deb",' electron-builder.json5
- cat electron-builder.json5
- yarn electron:build
- ls release
- ls release/*.*.*
cache:
key: "${CI_JOB_NAME}"
paths:
- node_modules/
- .cache/
artifacts:
name: "${CI_JOB_NAME}"
paths:
- release/*/*.exe
- release/*/**.exe.blockmap
- release/*/*.dmg
- release/*/**.dmg.blockmap
- release/*/*.rpm
- release/*/**.rpm.blockmap
- release/*/*.deb
- release/*/**.deb.blockmap
- release/*/*.AppImage
- release/*/**.AppImage.blockmap
- release/*/*.tar.gz
- release/*/**.tar.gz.blockmap
- release/*/*.tar.xz
- release/*/**.tar.xz.blockmap
- release/*/alpha.yml
- release/*/beta.yml
- release/*/dev.yml
- release/*/rc.yml
- release/*/stable.yml
- release/*/latest.yml
- release/*/alpha-*.yml
- release/*/beta-*.yml
- release/*/dev-*.yml
- release/*/rc-*.yml
- release/*/stable-*.yml
- release/*/latest-*.yml
# https://docs.gitlab.com/ee/ci/yaml/index.html#rules
# 极狐GitLab中文文档:https://docs.gitlab.cn/jh/ci/yaml/index.html#rules
rules:
# PR 到 main 分支时预执行
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
# PR 合并到 main 后执行、推送到 main 分支时
- if: $CI_COMMIT_BRANCH == "main"
build:npm:node:18.16.0:
stage: build
# 使用作者构建的镜像,无需运行 apt-get update && apt-get install -y rpm,节省时间,避免网络影响
image: xuxiaoweicomcn/node-rpm:18.16.0
variables:
# npm 缓存路径
NPM_CONFIG_CACHE: $CI_PROJECT_DIR/.cache
# electron 缓存路径
ELECTRON_CACHE: $CI_PROJECT_DIR/.cache/electron/cache
# electron-builder 缓存路径
ELECTRON_BUILDER_CACHE: $CI_PROJECT_DIR/.cache/electron-builder/cache
script:
- npm config set registry https://registry.npmmirror.com
- npm i
# 使用作者构建的镜像,无需运行 apt-get update && apt-get install -y rpm,即可构建 .rpm 产物,节省时间,避免网络影响
# - apt-get update
# - apt-get install -y rpm
- cat electron-builder.json5
# 增加 .rpm 产物
- sed -i '/"AppImage",/i \ \ \ \ \ \ "rpm",' electron-builder.json5
# 增加 .deb 产物
- sed -i '/"AppImage",/i \ \ \ \ \ \ "deb",' electron-builder.json5
- cat electron-builder.json5
- npm run electron:build
- ls release
- ls release/*.*.*
cache:
key: "${CI_JOB_NAME}"
paths:
- node_modules/
- .cache/
artifacts:
name: "${CI_JOB_NAME}"
paths:
- release/*/*.exe
- release/*/**.exe.blockmap
- release/*/*.dmg
- release/*/**.dmg.blockmap
- release/*/*.rpm
- release/*/**.rpm.blockmap
- release/*/*.deb
- release/*/**.deb.blockmap
- release/*/*.AppImage
- release/*/**.AppImage.blockmap
- release/*/*.tar.gz
- release/*/**.tar.gz.blockmap
- release/*/*.tar.xz
- release/*/**.tar.xz.blockmap
- release/*/alpha.yml
- release/*/beta.yml
- release/*/dev.yml
- release/*/rc.yml
- release/*/stable.yml
- release/*/latest.yml
- release/*/alpha-*.yml
- release/*/beta-*.yml
- release/*/dev-*.yml
- release/*/rc-*.yml
- release/*/stable-*.yml
- release/*/latest-*.yml
# https://docs.gitlab.com/ee/ci/yaml/index.html#rules
# 极狐GitLab中文文档:https://docs.gitlab.cn/jh/ci/yaml/index.html#rules
rules:
# PR 到 main 分支时预执行
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
# PR 合并到 main 后执行、推送到 main 分支时
- if: $CI_COMMIT_BRANCH == "main"
build:pnpm:node:18.16.0:
stage: build
# 使用作者构建的镜像,无需运行 apt-get update && apt-get install -y rpm,节省时间,避免网络影响
image: xuxiaoweicomcn/node-rpm:18.16.0
variables:
# npm 缓存路径
NPM_CONFIG_CACHE: $CI_PROJECT_DIR/.cache
# electron 缓存路径
ELECTRON_CACHE: $CI_PROJECT_DIR/.cache/electron/cache
# electron-builder 缓存路径
ELECTRON_BUILDER_CACHE: $CI_PROJECT_DIR/.cache/electron-builder/cache
script:
- yarn config set registry https://registry.npmmirror.com
- yarn global add pnpm
- pnpm config set registry https://registry.npmmirror.com
- pnpm install
# 使用作者构建的镜像,无需运行 apt-get update && apt-get install -y rpm,即可构建 .rpm 产物,节省时间,避免网络影响
# - apt-get update
# - apt-get install -y rpm
- cat electron-builder.json5
# 增加 .rpm 产物
- sed -i '/"AppImage",/i \ \ \ \ \ \ "rpm",' electron-builder.json5
# 增加 .deb 产物
- sed -i '/"AppImage",/i \ \ \ \ \ \ "deb",' electron-builder.json5
- cat electron-builder.json5
- pnpm run electron:build
- ls release
- ls release/*.*.*
cache:
key: "${CI_JOB_NAME}"
paths:
- node_modules/
- .cache/
artifacts:
name: "${CI_JOB_NAME}"
paths:
- release/*/*.exe
- release/*/**.exe.blockmap
- release/*/*.dmg
- release/*/**.dmg.blockmap
- release/*/*.rpm
- release/*/**.rpm.blockmap
- release/*/*.deb
- release/*/**.deb.blockmap
- release/*/*.AppImage
- release/*/**.AppImage.blockmap
- release/*/*.tar.gz
- release/*/**.tar.gz.blockmap
- release/*/*.tar.xz
- release/*/**.tar.xz.blockmap
- release/*/alpha.yml
- release/*/beta.yml
- release/*/dev.yml
- release/*/rc.yml
- release/*/stable.yml
- release/*/latest.yml
- release/*/alpha-*.yml
- release/*/beta-*.yml
- release/*/dev-*.yml
- release/*/rc-*.yml
- release/*/stable-*.yml
- release/*/latest-*.yml
# https://docs.gitlab.com/ee/ci/yaml/index.html#rules
# 极狐GitLab中文文档:https://docs.gitlab.cn/jh/ci/yaml/index.html#rules
rules:
# PR 到 main 分支时预执行
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
# PR 合并到 main 后执行、推送到 main 分支时
- if: $CI_COMMIT_BRANCH == "main"
include:
- /sync.yml