-
-
Notifications
You must be signed in to change notification settings - Fork 3
348 lines (309 loc) · 14.1 KB
/
cd.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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
name: Sillot CI/CD
# https://github.com/actions/runner-images/blob/main/images/
on:
push:
tags:
- "v*"
jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_version: ${{ steps.release_info.outputs.release_version }}
version: ${{ steps.version.outputs.value }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: pip install PyGithub
- name: Extract Sillot version from package.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: "jq .version app/package.json -r"
- name: Extract SiYuan version from package.json
uses: sergeysova/jq-action@v2
id: syv
with:
cmd: "jq .syv app/package.json -r"
- name: Extract SiYuan version from package.json
uses: sergeysova/jq-action@v2
id: sypv
with:
cmd: "jq .sypv app/package.json -r"
- id: thislatestR
uses: pozetroninc/github-action-get-latest-release@master
with:
# owner: Hi-Windom
# repo: Sillot
repository: ${{ github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
excludes: prerelease, draft
- name: Gather Sillot Release Information
id: release_info
# https://github.com/Hi-Windom/Sillot/issues/373
# 注意:创建或更新环境变量的步骤无权访问新值;$GITHUB_OUTPUT 需要定义步骤 id 才能稍后检索输出值,$GITHUB_ENV 则不需要
# 以下转换不再需要:
# changelog="${changelog//'%'/'%25'}"
# changelog="${changelog//$'\n'/'%0A'}"
# changelog="${changelog//$'\r'/'%0D'}"
run: |
echo "release_title=$(git show --format=%s --no-patch | head -1)" >> $GITHUB_OUTPUT
echo "release_version=v${{ steps.version.outputs.value }}_$(TZ=Asia/Shanghai date +'%Y%m%d')_syv${{ steps.syv.outputs.value }}" >> $GITHUB_OUTPUT
changelog1=$(python scripts/parse-changelog-HEAD.py -t ${{ github.ref }} -b ${{ steps.thislatestR.outputs.release }} Hi-Windom/Sillot)
changelog2=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} Hi-Windom/Sillot)
changelog3=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} Hi-Windom/Sillot-android)
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "release_body_sillot<<$EOF" >> $GITHUB_ENV
echo "$changelog1" >> $GITHUB_ENV
echo "$changelog2" >> $GITHUB_ENV
echo "$changelog3" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Gather SiYuan Release Information
id: release_info_siyuan
run: |
changelog=$(python scripts/parse-changelog.py -t v${{ steps.syv.outputs.value }} -b v${{ steps.sypv.outputs.value }} siyuan-note/siyuan)
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "release_body_siyuan<<$EOF" >> $GITHUB_ENV
echo "$changelog" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
release_name: ${{ steps.release_info.outputs.release_version }}
tag_name: ${{ github.ref }}
body: "${{ env.release_body_sillot }}\n---\n${{ env.release_body_siyuan }}"
draft: false
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ${{ matrix.config.os }}
needs: create_release
strategy:
matrix:
config:
- os: ubuntu-20.04
kernel_path: "../app/kernel-linux/SiYuan-Sillot-Kernel"
build_args: "-s -w -X github.com/Hi-Windom/Sillot/kernel/util.Mode=prod"
electron_args: "dist-linux"
goos: "linux"
goarch: "amd64"
suffix: "linux.AppImage"
- os: ubuntu-20.04
kernel_path: "../app/kernel-linux/SiYuan-Sillot-Kernel"
build_args: "-s -w -X github.com/Hi-Windom/Sillot/kernel/util.Mode=prod"
electron_args: "dist-linux"
goos: "linux"
goarch: "amd64"
suffix: "linux.tar.gz"
# - os: macos-latest
# kernel_path: "../app/kernel-darwin/SiYuan-Sillot-Kernel"
# build_args: "-s -w -X github.com/Hi-Windom/Sillot/kernel/util.Mode=prod"
# electron_args: "dist-darwin"
# goos: "darwin"
# goarch: "amd64"
# suffix: "mac.dmg"
# - os: macos-latest
# kernel_path: "../app/kernel-darwin-arm64/SiYuan-Sillot-Kernel"
# build_args: "-s -w -X github.com/Hi-Windom/Sillot/kernel/util.Mode=prod"
# electron_args: "dist-darwin-arm64"
# goos: "darwin"
# goarch: "arm64"
# suffix: "mac-arm64.dmg"
- os: windows-latest
kernel_path: "../app/kernel/SiYuan-Sillot-Kernel.exe"
build_args: "-s -w -H=windowsgui -X github.com/Hi-Windom/Sillot/kernel/util.Mode=prod"
electron_args: "dist"
goos: "windows"
gobin: "bin"
mingwsys: "MINGW64"
goarch: "amd64"
suffix: "win.exe"
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot
- name: Checkout subtree PSP
uses: actions/checkout@v4
with:
repository: K-Sillot/sillot-plugin-system
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/PSP
- name: Set up MingGW
uses: msys2/setup-msys2@v2
if: contains( matrix.config.goos, 'windows')
with:
install: p7zip mingw-w64-x86_64-lua
- name: Set up TDM-GCC
run: msys2 -c "bash go/src/github.com/Hi-Windom/Sillot/scripts/get-tdm-gcc.sh tdm https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm-1/tdm-gcc-10.3.0.exe" && echo "CC=${{ github.workspace }}/tdm/bin/gcc.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if: contains( matrix.config.goarch, '386')
working-directory: ${{ github.workspace }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Set up goversioninfo
run: go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo && go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo
if: contains( matrix.config.goos, 'windows')
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/kernel
env:
GO111MODULE: on
CGO_ENABLED: 1
GOOS: ${{ matrix.config.goos }}
GOPATH: ${{ github.workspace }}/go
GOARCH: ${{ matrix.config.goarch }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node pnpm
run: npm install -g pnpm
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app
- name: Change NPMRC File
run: pnpm config set registry https://registry.npmjs.org/ --location project
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app
- name: Install Node Dependencies
run: pnpm install --no-frozen-lockfile
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app
- name: Building UI
run: pnpm run build
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app
- name: Remove Build Directory
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/build
- name: Remove Kernel Directory for Linux
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/kernel-linux
- name: Remove Kernel Directory for Windows
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/kernel
# - name: Remove Kernel Directory for macOS
# uses: JesseTG/rm@v1.0.2
# with:
# path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/kernel-darwin
# - name: Remove Kernel Directory for macOS ARM64
# uses: JesseTG/rm@v1.0.2
# with:
# path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/kernel-darwin-arm64
- name: Generate Icon Resource and Properties/Version Info For Windows
run: ${{ github.workspace }}\go\${{ matrix.config.gobin }}\goversioninfo -platform-specific=true -icon="resource\icon.ico" -manifest="resource\goversioninfo.exe.manifest"
if: contains( matrix.config.goos, 'windows')
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/kernel
- name: Building Kernel
run: go build --tags fts5 -o "${{ matrix.config.kernel_path }}" -v -ldflags "${{ matrix.config.build_args }}"
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/kernel
env:
GO111MODULE: on
CGO_ENABLED: 1
GOOS: ${{ matrix.config.goos }}
GOPATH: ${{ github.workspace }}/go
GOARCH: ${{ matrix.config.goarch }}
- name: Building Electron
run: pnpm run ${{ matrix.config.electron_args }}
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app
- name: Upload Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 这里使用 bot
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: Sillot-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }}
asset_path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/build/Sillot-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}
asset_content_type: application/octet-stream
- name: zip WinPortable
uses: thedoctor0/zip-release@0.7.1
if: contains( matrix.config.goos, 'windows')
with:
type: 'zip'
filename: Sillot-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot/app/build/win-unpacked/
exclusions: '*.git*'
recursive_exclusions: 'LICENSES.chromium.html'
- name: Upload WinPortable to release
uses: actions/upload-release-asset@v1
if: contains( matrix.config.goos, 'windows')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 这里使用 bot
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: Sillot-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
asset_path: Sillot-${{ needs.create_release.outputs.release_version }}-win_Portable_.zip
asset_content_type: application/octet-stream
# Manual setup is required when the built-in version does not work correctly in windows2022
- name: Setup JDK 11
uses: actions/setup-java@v3
if: contains( matrix.config.goos, 'windows')
continue-on-error: true
with:
java-version: '17'
distribution: 'zulu'
overwrite-settings: true
- name: Setup Android SDK
uses: android-actions/setup-android@v3.2.0
if: contains( matrix.config.goos, 'windows')
- name: Install Android NDK
uses: nttld/setup-ndk@v1
if: contains( matrix.config.goos, 'windows')
with:
ndk-version: r25b
add-to-path: true
- name: Remove android Directory
uses: JesseTG/rm@v1.0.2
if: contains( matrix.config.goos, 'windows')
with:
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/SillotAndroid
- name: Checkout android repo
uses: actions/checkout@v4
if: contains( matrix.config.goos, 'windows')
with:
repository: Hi-Windom/Sillot-android
path: ${{ github.workspace }}/go/src/github.com/Hi-Windom/SillotAndroid
- name: Before android build
if: contains( matrix.config.goos, 'windows')
run: |
cd ${{ github.workspace }}/go/src/github.com/Hi-Windom/Sillot
.\scripts\sillot-android-build-action.bat
continue-on-error: false
- name: Build with Gradle
if: contains( matrix.config.goos, 'windows')
working-directory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/SillotAndroid
run: ./gradlew assembleAction --quiet --stacktrace
continue-on-error: false
- uses: r0adkll/sign-android-release@v1
if: contains( matrix.config.goos, 'windows')
name: Sign APK
id: sign_app
with:
releaseDirectory: ${{ github.workspace }}/go/src/github.com/Hi-Windom/SillotAndroid/app/build/outputs/apk/action
signingKeyBase64: ${{ secrets.APK_SIGN_KEY_JKS_BASE64 }}
alias: ${{ secrets.APK_SIGN_KEY_ALIAS }}
keyStorePassword: ${{ secrets.APK_SIGN_KEY_JKS_PW }}
keyPassword: ${{ secrets.APK_SIGN_KEY_PW }}
env:
# override default build-tools version -- optional
BUILD_TOOLS_VERSION: "30.0.3"
- name: Upload APK to release
uses: actions/upload-release-asset@v1
if: contains( matrix.config.goos, 'windows')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: Sillot-${{ needs.create_release.outputs.release_version }}-debug.apk
asset_path: ${{steps.sign_app.outputs.signedReleaseFile}}
asset_content_type: application/octet-stream