-
-
Notifications
You must be signed in to change notification settings - Fork 343
450 lines (401 loc) · 16.2 KB
/
linux.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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
name: Linux
on:
workflow_call:
workflow_dispatch:
env:
APP_ID: io.github.nuttyartist.notes
jobs:
deb:
name: deb (${{ matrix.build-type }}, Qt ${{ matrix.qt-version-major }}, ${{ matrix.container != '' && matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container:
image: zjeffer/notes:${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
# Ubuntu's release cycle: https://wiki.ubuntu.com/Releases
- os: ubuntu-20.04
image: ubuntu-20_04
qt-version-major: 5
build-type: release
- os: ubuntu-22.04
image: ubuntu-22_04
qt-version-major: 6
build-type: release
# - os: ubuntu-20.04
# qt-version-major: 6
# build-type: release
steps:
- name: Install other dependencies in docker container
# fix git error "fatal: detected dubious ownership in repository"
run: git config --global --add safe.directory "${PWD}"
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up variables
shell: bash
id: vars
run: |
set -x
distro_id=$(grep -oPm1 '^ID="?\K[^"]+' /etc/os-release)
if [ -z "${distro_id}" ]
then
echo 'Fatal: Failed to extract distro ID from /etc/os-release'
exit 1
fi
distro_codename=$(grep -oPm1 '^VERSION_CODENAME="?\K[^"]+' /etc/os-release)
if [ -z "${distro_codename}" ]
then
echo 'Fatal: Failed to extract distro codename from /etc/os-release'
exit 1
fi
echo "distro_name=${distro_id}-${distro_codename}" >> "${GITHUB_OUTPUT}"
- name: Install build dependencies
if: matrix.image == ''
run: |
sudo apt update
sudo apt install -y gcc cmake lintian ${{ matrix.qt-version-major == '6' && 'qt6-base-private-dev qt6-declarative-dev libgl-dev' || 'qtbase5-private-dev qtdeclarative5-dev' }}
- name: Setup GCC problem matcher
uses: ammaraskar/[email protected]
- name: Build (${{ matrix.build-type }})
env:
VERBOSE: 1
run: |
cmake --warn-uninitialized --warn-unused-vars \
-B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DGIT_REVISION=${{ github.ref_type != 'tag' && 'ON' || 'OFF' }} \
-DCMAKE_INSTALL_PREFIX=/usr \
-DPRO_VERSION=OFF
cmake --build build --parallel $(nproc)
- name: Create deb package
run: |
cd build
cpack -G DEB
- name: Grab deb package name
id: deb
shell: bash
run: |
set -x
if ! path=$(find build/ -maxdepth 1 -name '*.deb' -print -quit)
then
echo 'Fatal: Unable to find deb package'
exit 1;
fi
echo "name=$(basename "${path%.*}")" >> "${GITHUB_OUTPUT}"
echo "path=${path}" >> "${GITHUB_OUTPUT}"
- name: Run lintian
run: |
lintian '${{ steps.deb.outputs.path }}'
- name: Upload deb package
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ steps.deb.outputs.name }}-qt${{ matrix.qt-version-major }}-${{ steps.vars.outputs.distro_name }}-${{ matrix.build-type }}
path: ${{ steps.deb.outputs.path }}
rpm:
name: rpm (${{ matrix.build-type }}, Qt ${{ matrix.qt-version-major }}, ${{ matrix.container != '' && matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
# Fedora's release cycle: https://docs.fedoraproject.org/en-US/releases/lifecycle/
container: fedora:38
qt-version-major: 6
build-type: release
- os: ubuntu-20.04
container: opensuse/leap:15
qt-version-major: 6
build-type: release
steps:
- name: Install build dependencies
env:
PKG_MANAGER: ${{ startsWith(matrix.container, 'fedora') && 'dnf' || 'zypper' }}
# Fedora doesn't include libxkbcommon-devel as a dependency of Qt 6, so have to install it manually.
PKG_LIST: ${{ startsWith(matrix.container, 'fedora') && 'libxkbcommon-devel qt6-qtbase-private-devel qt6-qtdeclarative-devel' || 'qt6-base-private-devel qt6-declarative-devel' }}
run: |
${{ env.PKG_MANAGER }} update -y
${{ env.PKG_MANAGER }} install -y cmake gcc git ${{ env.PKG_LIST }} rpm-build rpmlint
# Prevent git's dubious ownership message
git config --global --add safe.directory "${PWD}"
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up variables
shell: bash
id: vars
run: |
set -x
distro_id=$(grep -oPm1 '^ID="?\K[^"]+' /etc/os-release)
if [ -z "${distro_id}" ]
then
echo 'Failed to extract distro ID from /etc/os-release.'
exit 1
fi
version_id=$(grep -oPm1 '^VERSION_ID="?\K[^"]+' /etc/os-release)
if [ -z "${version_id}" ]
then
echo 'Failed to extract version id from /etc/os-release.'
exit 1
fi
echo "distro_name=${distro_id}-${version_id}" >> "${GITHUB_OUTPUT}"
- name: Setup GCC problem matcher
uses: ammaraskar/[email protected]
- name: Build (${{ matrix.build-type }})
env:
VERBOSE: 1
# openSUSE defaults to GCC 7, which doesn't support the filesystem library from C++17,
# and causes trouble compiling for Qt 6. So we have to manully specify GCC 10 instead.
CXX: ${{ startsWith(matrix.container, 'opensuse') && 'g++-10' || 'g++' }}
run: |
cmake --warn-uninitialized --warn-unused-vars \
-B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DGIT_REVISION=${{ github.ref_type != 'tag' && 'ON' || 'OFF' }} \
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
-DUPDATE_CHECKER=OFF \
-DUSE_QT_VERSION=${{ matrix.qt-version-major }} \
-DPRO_VERSION=OFF
cmake --build build --parallel $(nproc)
- name: Create rpm package
run: |
cd build
cpack -G RPM
- name: Grab rpm package name
id: rpm
shell: bash
run: |
set -x
if ! path=$(find build/ -maxdepth 1 -name '*.rpm' -print -quit)
then
echo 'Fatal: Unable to find rpm package!'
exit 1;
fi
echo "name=$(basename "${path%.*}")" >> "${GITHUB_OUTPUT}"
echo "path=${path}" >> "${GITHUB_OUTPUT}"
- name: Run rpmlint
run: |
rpmlint '${{ steps.rpm.outputs.path }}'
- name: Upload rpm package
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ steps.rpm.outputs.name }}-qt${{ matrix.qt-version-major }}-${{ steps.vars.outputs.distro_name }}-${{ matrix.build-type }}
path: ${{ steps.rpm.outputs.path }}
# Build the AppImage using official Qt releases, downloaded by aqtinstall.
# This is also done for macOS and Windows, just to make sure we use the exact same Qt version across all three OSes.
#
# NOTE: This job uses a fixed Qt version (set in the 'qt-version' key below)!
# So, remember to keep it updated whenever a new Qt version is available on aqtinstall.
appimage-aqtinstall:
name: AppImage (${{ matrix.build-type }}, Qt ${{ matrix.qt-version }}, ${{ matrix.container != '' && matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
container: ubuntu:20.04
build-type: release
qt-version: 5.15.2
- os: ubuntu-20.04
container: ubuntu:20.04
build-type: release
qt-version: 6.4.3
steps:
- name: Install other dependencies in docker container
# - appstream: Used to validate the AppStream metadata file.
# - cmake: Used to help build the application.
# - curl: Used to download the linuxdeploy AppImage tool.
# - desktop-file-utils: Used to validate the desktop file.
# - git: To clone this repository.
# - libfontconfig1: Used as dependency of the resulting AppImage.
# - libxcb-cursor0: Used as dependency of the resulting AppImage.
# - libxkbcommon-x11-0: Used as dependency of the resulting AppImage.
# - python3/python3-pip: Used by aqtinstall.
# - sudo: Used by most GitHub actions to install things.
if: matrix.container != ''
run: |
# Configure the timezone, otherwise 'install-qt-action' gets stuck at 'configuring tzdata'.
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
echo UTC > /etc/timezone
# install packages
apt update
apt install -y appstream cmake curl desktop-file-utils git libfontconfig1 libxcb-cursor0 libxkbcommon-x11-0 python3 python3-pip sudo
# Upgrade to the latest setuptools, as Ubuntu's python3-setuptools package has compatibility issues with aqtinstall.
python3 -m pip install --upgrade setuptools
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup variables
shell: bash
id: vars
run: |
set -x
version=$(grep -oPm1 '\bAPP_VERSION +\K[^)]+' CMakeLists.txt)
if [ -z "${version}" ]
then
echo 'Failed to extract app version from CMakeLists.txt.'
exit 1
fi
if [ '${{ github.ref_type }}' != 'tag' ]
then
version="${version}+g${GITHUB_SHA::7}"
fi
artifact_name="Notes_${version}-Qt${{ matrix.qt-version }}-x86_64"
if [ '${{ matrix.build-type }}' == 'debug' ]
then
file_name="${artifact_name}-debug.AppImage"
else
file_name="${artifact_name}.AppImage"
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
echo "artifact_name=${artifact_name}" >> "${GITHUB_OUTPUT}"
echo "file_name=${file_name}" >> "${GITHUB_OUTPUT}"
- name: Install Qt ${{ matrix.qt-version }} (aqtinstall)
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
# Prevents the installation of a custom Python build, potentially linked against an unsupported version of glibc.
setup-python: false
cache: true
- name: Install Qt 6 system dependencies
# 'libmysqlclient21' is actually only needed by linuxdeploy for Qt 6 builds. I'm including it here just for convenience.
if: startsWith(matrix.qt-version, '6.')
run: |
sudo apt update
sudo apt install -y libxkbcommon-dev libmysqlclient21
# TODO: Figure out why this error only occurs on the Linux container when building with -DGIT_REVISION=ON
# The error: fatal: detected dubious ownership in repository
- name: Prevent git's dubious ownership message
if: github.ref_type != 'tag'
run: |
git config --global --add safe.directory "${PWD}"
- name: Build (${{ matrix.build-type }})
env:
VERBOSE: 1
run: |
cmake --warn-uninitialized --warn-unused-vars \
-B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DGIT_REVISION=${{ github.ref_type != 'tag' && 'ON' || 'OFF' }} \
-DCMAKE_INSTALL_PREFIX=/usr \
-DPRO_VERSION=OFF
cmake --build build --parallel $(nproc)
- name: (FIXME) Run qmllint
if: startsWith(matrix.qt-version, '6.')
run: |
cmake --build build --target all_qmllint || true
- name: Install (${{ matrix.build-type }})
run: |
make -C build DESTDIR=Notes install
- name: Setup linuxdeploy
run: |
cd build
curl -fLO --retry 10 https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
- name: Setup Qt plugin for linuxdeploy
run: |
cd build
curl -fLO --retry 10 https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod +x linuxdeploy-plugin-qt-x86_64.AppImage
- name: Install useless dependencies to make linuxdeploy happy
# We won't use any of these sql drivers, but install them anyway so linuxdeploy doesn't fail.
run: |
sudo apt update
sudo apt install -y libpq5 libodbc1
- name: Deploy (${{ matrix.build-type }})
env:
APPIMAGE_EXTRACT_AND_RUN: 1
run: |
export QML_SOURCES_PATHS="${PWD}/src/qml"
cd build
./linuxdeploy-x86_64.AppImage --appdir Notes --plugin qt
- name: Remove unnecessary Qt plugins and libraries
shell: bash
run: |
set -x
set -e
cd build/Notes
if [[ '${{ matrix.qt-version }}' == 5.* ]]
then
# The bearer plugin has caused problems for us in the past. Plus, it was removed altogether in Qt 6.
rm -rv usr/plugins/bearer
fi
# We only use the SQLite Qt driver, so it's fine to delete others.
rm -v usr/plugins/sqldrivers/libqsqlodbc.so
rm -v usr/plugins/sqldrivers/libqsqlpsql.so
if [[ '${{ matrix.qt-version }}' == 6.* ]]
then
# The Qt 6 build also has a MySQL Qt driver we don't use.
rm -v usr/plugins/sqldrivers/libqsqlmysql.so
rm -v usr/lib/libmysqlclient.so.*
fi
- name: Validate AppStream metadata
if: matrix.container != 'ubuntu:20.04'
run: |
cd build/Notes
appstreamcli validate --verbose 'usr/share/metainfo/${{ env.APP_ID }}.metainfo.xml'
- name: Validate desktop file
run: |
cd build/Notes
desktop-file-validate 'usr/share/applications/${{ env.APP_ID }}.desktop'
- name: Build AppImage (${{ matrix.build-type }})
env:
APPIMAGE_EXTRACT_AND_RUN: 1
run: |
cd build
export VERSION='${{ steps.vars.outputs.version }}'
./linuxdeploy-x86_64.AppImage --appdir Notes --output appimage
mv -v Notes*.AppImage '${{ steps.vars.outputs.file_name }}'
- name: Upload AppImage artifact (${{ matrix.build-type }})
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ steps.vars.outputs.artifact_name }}-${{ runner.os }}-${{ matrix.build-type }}
path: build/${{ steps.vars.outputs.file_name }}
snap:
name: snap
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install snapcraft
run: |
sudo snap install snapcraft --classic
- name: Set up LXD
run: |
sudo usermod -a -G lxd "${USER}"
sudo lxd init --auto
sudo iptables -P FORWARD ACCEPT
- name: Build
run: |
sg lxd -c 'snap run snapcraft -v'
- name: Grab snap package name
id: snap
shell: bash
run: |
set -x
if ! path=$(find . -maxdepth 1 -name '*.snap' -print -quit)
then
echo 'Fatal: Unable to find snap package'
exit 1
fi
echo "name=$(basename "${path%.*}")" >> "${GITHUB_OUTPUT}"
echo "path=${path}" >> "${GITHUB_OUTPUT}"
- name: Upload snap package
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ steps.snap.outputs.name }}.snap
path: ${{ steps.snap.outputs.path }}