-
Notifications
You must be signed in to change notification settings - Fork 4
377 lines (333 loc) · 11.3 KB
/
build.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
name: Build
# Complete packaging in the future
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
permissions: write-all
jobs:
build:
name: Build ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
rid: [linux-x64, win-x64, win-arm64, macos-arm64]
include:
- rid: linux-x64
rust_target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
qt_arch: gcc_64
- rid: win-x64
msvc_arch: x64
rust_target: x86_64-pc-windows-msvc
vcpkg_target_triplet: 'x64-windows-static'
os: windows-latest
- rid: win-arm64
msvc_arch: arm64
rust_target: aarch64-pc-windows-msvc
vcpkg_target_triplet: 'arm64-windows-static'
os: windows-latest
- rid: macos-arm64
rust_target: aarch64-apple-darwin
os: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up GCC
if: startsWith(matrix.rid, 'linux-')
uses: egor-tensin/[email protected]
with:
version: 14
platform: x64
- name: Setup toolchains for building Qt
if: ${{ !matrix.qt_arch }}
shell: pwsh
run: |
if (Get-Command apt-get -ErrorAction SilentlyContinue) {
$deps = 'autoconf', 'automake', 'autoconf-archive', '^libxcb.*-dev',
'libx11-xcb-dev', 'libxrender-dev', 'libxi-dev',
'libxkbcommon-dev', 'libxkbcommon-x11-dev',
'libglu1-mesa-dev', 'libegl1-mesa-dev'
sudo apt-get update
sudo apt-get install -y @deps
} elseif (Get-Command brew -ErrorAction SilentlyContinue) {
$deps = 'autoconf', 'automake', 'autoconf-archive', 'libtool'
brew install @deps
}
- name: Install Qt
uses: jurplel/install-qt-action@v4
if: matrix.qt_arch
with:
version: '6.6.3'
arch: ${{ matrix.qt_arch }}
cache: true
- name: Setup Rust toolchain
uses: moonrepo/setup-rust@v1
with:
channel: stable
targets: ${{ matrix.rust_target }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Cache corrosion
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/build/_deps
${{ github.workspace }}/build/*/cargo/build
!${{ github.workspace }}/build/*/cargo/build/**/incremental
${{ github.workspace }}/build/corrosion/**/target
!${{ github.workspace }}/build/corrosion/**/target/**/incremental
key: corrosion-${{ matrix.rid }}
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgConfigurationJsonGlob: 'vcpkg-configuration.json'
vcpkgJsonGlob: 'vcpkg.json'
- name: Build
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$rid = '${{ matrix.rid }}'
$vcpkgTargetTriplet = '${{ matrix.vcpkg_target_triplet }}'
$qtArch = '${{ matrix.qt_arch }}'
$additionalConfigureArgs = @()
if ($rid.StartsWith('win-')) {
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} "\Microsoft Visual Studio\Installer\vswhere.exe") -property installationpath
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=${{ matrix.msvc_arch }} -host_arch=x64'
$additionalConfigureArgs += '-DPKG_CONFIG_EXECUTABLE:FILEPATH=./build/vcpkg_installed/x64-windows/tools/pkgconf/pkgconf.exe'
}
if ($vcpkgTargetTriplet) {
$additionalConfigureArgs += "-DVCPKG_TARGET_TRIPLET:STRING=$vcpkgTargetTriplet"
}
if (-not $qtArch) {
$additionalConfigureArgs += "-DVCPKG_MANIFEST_FEATURES=qt-from-vcpkg"
}
$additionalConfigureArgs += "-DRust_CARGO_TARGET=${{ matrix.rust_target }}"
# Install as portable software
$additionalConfigureArgs += '-DCMAKE_INSTALL_LIBDIR=.'
$additionalConfigureArgs += '-DCMAKE_INSTALL_BINDIR=.'
if ($rid.StartsWith('linux-')) {
$additionalConfigureArgs += '-DCMAKE_INSTALL_RPATH=$ORIGIN'
}
if ($rid.StartsWith('macos-')) {
$additionalConfigureArgs += '-DCMAKE_INSTALL_RPATH=@loader_path'
}
cmake --preset native @additionalConfigureArgs
cmake --build --preset native-release
- name: Archive files
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
# Install the built files
cmake --install ./build --prefix ./installed
# Hack: fix install name for `libslint_cpp.so` on macOS
if ('${{ matrix.rid }}'.StartsWith('macos-')) {
# Slint did not set the install dir to `@rpath` when used via FetchContent.
# Do some hack to fix it when packaging.
# https://github.com/slint-ui/slint/blob/461632717a3ffdd1f9e75cfb7cbfce0763dc0129/api/cpp/CMakeLists.txt#L145
$loadCmdsForLibSlint = otool -l ./installed/libslint_cpp.dylib
$idPattern = '\s*cmd\s+LC_ID_DYLIB\s*cmdsize\s+\d+\s*name\s+([^\(\r\n]*?)\s+\(offset \d+\)'
$idMatched = [regex]::Matches($loadCmdsForLibSlint, $idPattern)[0]
if ($idMatched) {
$oldId = $idMatched.Groups[1].Value
echo "Old LC_ID_DYLIB for libslint_cpp.dylib is '$oldId'"
echo "Fixing it to '@rpath/libslint_cpp.dylib'"
install_name_tool -id '@rpath/libslint_cpp.dylib' ./installed/libslint_cpp.dylib
install_name_tool -change $oldId '@rpath/libslint_cpp.dylib' ./installed/sast-evento
}
}
# Remove unnecessary files
Set-Location ./installed
Remove-Item -Force -Recurse ./lib
Remove-Item -Force -Recurse ./include
Remove-Item -Force slint-compiler*
Remove-Item -Force *.lib
Remove-Item -Force *.a
Set-Location ..
# Archive the files
if ('${{ runner.os }}' -eq 'Windows') {
Compress-Archive -Path ./installed/* -DestinationPath ./files.zip
} else {
tar -czf ./files.tar.gz -C ./installed .
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: files-${{ matrix.rid }}
path: ${{ runner.os != 'Windows' && './files.tar.gz' || './files.zip' }}
package-win:
name: Package ${{ matrix.rid }} (Inno Setup)
runs-on: windows-latest
needs: build
strategy:
fail-fast: false
matrix:
rid: [win-x64, win-arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: files-${{ matrix.rid }}
- name: Extract files
id: extract
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
Expand-Archive -Path ./files.zip -DestinationPath ./files
$version = Get-Content -Path ./files/sast-evento-version.txt
Write-Output "version=$version" >> $Env:GITHUB_OUTPUT
- name: Inno Setup
uses: Minionguyjpro/[email protected]
with:
path: ./deploy/win-installer.iss
options: /O+ /dMyAppVersion=${{ steps.extract.outputs.version }}
- name: Upload installer
uses: actions/upload-artifact@v4
with:
name: installer-${{ matrix.rid }}
path: ./deploy/installer.exe
package-deb:
name: Package ${{ matrix.rid }} (deb)
runs-on: ubuntu-24.04
needs: build
strategy:
fail-fast: false
matrix:
rid: [linux-x64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: files-${{ matrix.rid }}
- name: Extract files
shell: bash
run: |
mkdir -p ./files
tar -xzf ./files.tar.gz -C ./files
- name: Package
shell: bash
run: |
bash ./deploy/create-deb.sh ./files
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.rid }}
path: ./sast-evento.deb
package-pacman:
name: Package ${{ matrix.rid }} (pacman)
runs-on: ubuntu-24.04
needs: build
strategy:
fail-fast: false
matrix:
rid: [linux-x64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: files-${{ matrix.rid }}
- name: Package
shell: bash
run: |
mv ./files.tar.gz ./deploy/pacman/files.tar.gz
cp ./ui/assets/image/icon/evento.svg ./deploy/pacman/icon.svg
cat | docker run -i --rm -v $(pwd)/deploy/pacman:/pkg -w /pkg archlinux/archlinux:base-devel /bin/bash -e << EOF
useradd build -m
passwd -d build
printf 'build ALL=(ALL) ALL\n' | tee -a /etc/sudoers
chown -R build:build .
sudo -u build makepkg -f --nodeps --noconfirm
EOF
sudo rm ./deploy/pacman/*-debug-*.pkg.tar.zst
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: pacman-${{ matrix.rid }}
path: ./deploy/pacman/*.pkg.tar.zst
package-macos:
name: Package ${{ matrix.rid }} (dmg)
runs-on: macos-latest
needs: build
strategy:
fail-fast: false
matrix:
rid: [macos-arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: files-${{ matrix.rid }}
- name: Extract files
shell: bash
run: |
mkdir -p ./files
tar -xzf ./files.tar.gz -C ./files
- name: Construct macOS app bundle
shell: bash
run: |
bash ./deploy/create-mac-app.sh ./files './sast-evento.app'
- name: Package
uses: L-Super/create-dmg-actions@v1
with:
dmg_name: 'sast-evento'
src_dir: './sast-evento.app'
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: dmg-${{ matrix.rid }}
path: ./sast-evento.dmg
publish-release:
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
needs:
- package-win
- package-deb
- package-pacman
- package-macos
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Organize artifacts
shell: pwsh
run: |
Set-Location ./artifacts
Remove-Item -Force -Recurse ./files-*
Get-ChildItem -Directory -Path . | ForEach-Object {
Write-Host "Compressing $($_.Name)"
$dirPath = $_.FullName
$zipPath = "$dirPath.zip"
Compress-Archive -Path $dirPath -DestinationPath $zipPath
Remove-Item -Path $dirPath -Recurse
}
- name: Release (GitHub)
uses: ncipollo/release-action@v1
with:
artifacts: ./artifacts/*
allowUpdates: true
draft: false
omitBody: true