This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
387 lines (335 loc) · 12.8 KB
/
publish.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: Publish
on: [ push, pull_request ]
env:
CONFIGURATION: Release
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SDK_VERSION: 6.0.x
NET_CORE_VERSION: net6.0
jobs:
publish:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
with:
submodules: recursive
- name: Add MSBuild to PATH
if: startsWith(matrix.os, 'windows-')
uses: microsoft/setup-msbuild@v1.3.1
- name: Verify MSBuild
if: startsWith(matrix.os, 'windows-')
run: msbuild -version
- name: Verify g++ on Linux
if: startsWith(matrix.os, 'ubuntu-')
shell: sh
run: g++ --version
- name: Verify g++ on macOS
if: startsWith(matrix.os, 'macos-')
shell: sh
run: g++ --version
- name: Verify Python and pip packages (win&linux)
if: startsWith(matrix.os, 'windows-') || startsWith(matrix.os, 'ubuntu-')
run: |
python --version
pip install requests
pip install pyinstaller
pip install wget
- name: Verify Python and pip packages (mac)
if: startsWith(matrix.os, 'macos-')
run: |
python3 --version
python3 -m pip install requests
brew install pyinstaller
python3 -m pip install wget
- name: Restore NuGet Packages
if: startsWith(matrix.os, 'windows-')
shell: pwsh
run: |
Set-StrictMode -Version Latest
cd ConfigGenerator
nuget restore
- name: Publish ConfigGenerator on Linux
if: startsWith(matrix.os, 'ubuntu-')
shell: sh
run: |
cd ConfigGenerator
g++ -o ConfigGenerator Unix-version/src/source.cpp
mkdir out
cp "ConfigGenerator" "out/"
- name: Publish ConfigGenerator on macOS
if: startsWith(matrix.os, 'macos-')
shell: sh
run: |
cd ConfigGenerator
g++ -o ConfigGenerator Unix-version/src/source.cpp
mkdir out
cp "ConfigGenerator" "out/"
- name: Publish ConfigGenerator on Windows
if: startsWith(matrix.os, 'windows-')
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
cd ConfigGenerator
msbuild -t:Build -p:Configuration=Release -p:OutDir="out\" -nologo
- name: Publish Updater on Unix
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
env:
VARIANTS: linux osx
shell: sh
run: |
pyinstaller -F Updater/src/Updater.py --distpath=out/
- name: Publish Updater on Windows
if: startsWith(matrix.os, 'windows-')
run: |
Set-StrictMode -Version Latest
New-Item -Name out -type "directory"
pyinstaller -i Updater/src/logo.ico -F --version-file Updater/src/version Updater/src/Updater.py --distpath=out/
- name: Publish main on Unix
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
env:
VARIANTS: linux osx
shell: sh
run: |
pyinstaller -F src/main.py --distpath=out/
- name: Publish main on Windows
if: startsWith(matrix.os, 'windows-')
run: |
Set-StrictMode -Version Latest
pyinstaller -i src/logo.ico -F --version-file src/version src/main.py --distpath=out/
- name: Create zip file on Linux
if: startsWith(matrix.os, 'ubuntu-')
shell: sh
run: |
cp "Updater/src/config.json" "out/"
cp "Updater/src/update.sh" "out/"
cp "src/config.conf" "out/"
cp "ERRORCODE.html" "out/"
cp "ConfigGenerator/out/ConfigGenerator" "out/"
# By default use fastest compression
seven_zip_args="-mx=1"
zip_args="-1"
# Include extra logic for builds marked for release
case "$GITHUB_REF" in
"refs/tags/"*)
# Tweak compression args for release publishing
seven_zip_args="-mx=9 -mfb=258 -mpass=15"
zip_args="-9"
esac
case "$(uname -s)" in
"Darwin")
# We prefer to use zip on OS X as 7z implementation on that OS doesn't handle file permissions (chmod +x)
if command -v zip >/dev/null; then
(
cd "${GITHUB_WORKSPACE}/out"
zip -q -r $zip_args "../Library-linux.zip" .
)
elif command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/Library-linux.zip" "${GITHUB_WORKSPACE}/out/*"
else
echo "ERROR: No supported zip tool!"
return 1
fi
;;
*)
if command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/Library-linux.zip" "${GITHUB_WORKSPACE}/out/*"
elif command -v zip >/dev/null; then
(
cd "${GITHUB_WORKSPACE}/out"
zip -q -r $zip_args "../Library-linux.zip" .
)
else
echo "ERROR: No supported zip tool!"
return 1
fi
;;
esac
- name: Create zip file on macOS
if: startsWith(matrix.os, 'macos-')
shell: sh
run: |
cp "Updater/src/config.json" "out/"
cp "Updater/src/update.sh" "out/"
cp "ConfigGenerator/Unix-version/res/com.qhy040404.library.plist" "out/"
cp "src/config.conf" "out/"
cp "ERRORCODE.html" "out/"
cp "ConfigGenerator/out/ConfigGenerator" "out/"
# By default use fastest compression
seven_zip_args="-mx=1"
zip_args="-1"
# Include extra logic for builds marked for release
case "$GITHUB_REF" in
"refs/tags/"*)
# Tweak compression args for release publishing
seven_zip_args="-mx=9 -mfb=258 -mpass=15"
zip_args="-9"
esac
case "$(uname -s)" in
"Darwin")
# We prefer to use zip on OS X as 7z implementation on that OS doesn't handle file permissions (chmod +x)
if command -v zip >/dev/null; then
(
cd "${GITHUB_WORKSPACE}/out"
zip -q -r $zip_args "../Library-osx.zip" .
)
elif command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/Library-osx.zip" "${GITHUB_WORKSPACE}/out/*"
else
echo "ERROR: No supported zip tool!"
return 1
fi
;;
*)
if command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/Library-osx.zip" "${GITHUB_WORKSPACE}/out/*"
elif command -v zip >/dev/null; then
(
cd "${GITHUB_WORKSPACE}/out"
zip -q -r $zip_args "../Library-osx.zip" .
)
else
echo "ERROR: No supported zip tool!"
return 1
fi
;;
esac
- name: Create zip file on Windows
if: startsWith(matrix.os, 'windows-')
shell: pwsh
run: |
Copy-Item "Updater\src\config.json" "out"
Copy-Item "Updater\src\update.bat" "out"
Copy-Item "src\config.conf" "out"
Copy-Item "ERRORCODE.html" "out"
Copy-Item "ConfigGenerator\out\*" "out"
# By default use fastest compression
$compressionArgs = '-mx=1'
# Include extra logic for builds marked for release
if ($env:GITHUB_REF -like 'refs/tags/*') {
# Tweak compression args for release publishing
$compressionArgs = '-mx=9', '-mfb=258', '-mpass=15'
}
7z a -bd -slp -tzip -mm=Deflate $compressionArgs "out\Library-win.zip" "$env:GITHUB_WORKSPACE\out\*"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
- name: Upload Library-linux
if: startsWith(matrix.os, 'ubuntu-')
continue-on-error: true
uses: actions/upload-artifact@v3.1.3
with:
name: ${{ matrix.os }}_Library-linux
path: out/Library-linux.zip
- name: Upload Library-osx
if: startsWith(matrix.os, 'macos-')
continue-on-error: true
uses: actions/upload-artifact@v3.1.3
with:
name: ${{ matrix.os }}_Library-osx
path: Library-osx.zip
- name: Upload Library-win
if: startsWith(matrix.os, 'windows-')
continue-on-error: true
uses: actions/upload-artifact@v3.1.3
with:
name: ${{ matrix.os }}_Library-win
path: out/Library-win.zip
release:
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Download Library-osx artifact from macos-latest
uses: actions/download-artifact@v3.0.2
with:
name: macos-latest_Library-osx
path: upload
- name: Download Library-linux artifact from ubuntu-latest
uses: actions/download-artifact@v3.0.2
with:
name: ubuntu-latest_Library-linux
path: upload
- name: Download Library-win artifact from windows-latest
uses: actions/download-artifact@v3.0.2
with:
name: windows-latest_Library-win
path: upload
- name: Generate SHA-512 checksums
shell: sh
run: |
set -eu
(
cd "upload"
sha512sum *.zip > SHA512SUMS
)
- name: Upload SHA512SUMS
continue-on-error: true
uses: actions/upload-artifact@v3.1.3
with:
name: SHA512SUMS
path: upload/SHA512SUMS
- name: Generate release body
continue-on-error: true
uses: qhy040404/auto-generate-release-body@v1.1.5
with:
changelog: 'Changelog.md'
template: '.github/RELEASE_TEMPLATE.md'
tag: ${{ github.ref_name }}
template-data: '* Automated release body.'
fore-delimiter: ${{ github.ref_name }}
back-delimiter: '---'
- name: Create Library GitHub release
id: github_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: v${{ github.ref }}
body_path: .github/RELEASE_TEMPLATE.md
prerelease: false
- name: Upload Library-linux to GitHub release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.github_release.outputs.upload_url }}
asset_path: upload/Library-linux.zip
asset_name: Library-linux.zip
asset_content_type: application/zip
- name: Upload Library-osx to GitHub release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.github_release.outputs.upload_url }}
asset_path: upload/Library-osx.zip
asset_name: Library-osx.zip
asset_content_type: application/zip
- name: Upload Library-win to GitHub release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.github_release.outputs.upload_url }}
asset_path: upload/Library-win.zip
asset_name: Library-win.zip
asset_content_type: application/zip
- name: Upload SHA512SUMS to GitHub release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.github_release.outputs.upload_url }}
asset_path: upload/SHA512SUMS
asset_name: SHA512SUMS
asset_content_type: text/plain