Repository navigation
312 lines (279 loc) · 14.8 KB
/
Copy pathLinuxAppImage.yml
File metadata and controls
312 lines (279 loc) · 14.8 KB
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
name: Linux_AppImage
on:
workflow_dispatch:
permissions:
contents: read
env:
QT_VERSION: '6.11.3'
QT_MODULES: 'qtspeech qtmultimedia'
# Release only triplet, the dependencies are built once, not in the debug and release configuration
VCPKG_TRIPLET: x64-linux-release
jobs:
build_ubuntu:
# The oldest supported Ubuntu, the AppImage runs on the distributions with the same or a newer glibc
runs-on: ubuntu-22.04
timeout-minutes: 150
permissions:
contents: read
# GitHub artifact attestations of the AppImage
id-token: write
attestations: write
artifact-metadata: write
env:
GNUPGHOME: ${{ github.workspace }}/gnupg
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg-binary-cache
VCPKG_DISABLE_METRICS: 1
defaults:
run:
shell: bash
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxcb-cursor0 libspeechd2 gnupg2 wget appstream libcups2 libcups2-dev librsvg2-bin
# Requirements of Qt (the list of install-qt-action, which does not install them when Qt is restored
# from the cache)
sudo apt-get install -y build-essential libgl1-mesa-dev libgstreamer-gl1.0-0 libpulse-dev libxcb-glx0 \
libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 \
libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb1 \
libxkbcommon-dev libxkbcommon-x11-0 libxcb-xkb-dev libxcb-cursor0
wget -q -c "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x appimagetool-x86_64.AppImage
sudo mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool
- name: 'GPG: Configure'
run: |
rm -rf "$GNUPGHOME"
install -d -m 700 "$GNUPGHOME"
echo "use-agent" >> "$GNUPGHOME/gpg.conf"
echo "pinentry-mode loopback" >> "$GNUPGHOME/gpg.conf"
echo "allow-loopback-pinentry" >> "$GNUPGHOME/gpg-agent.conf"
echo "allow-preset-passphrase" >> "$GNUPGHOME/gpg-agent.conf"
gpgconf --kill gpg-agent
- name: 'GPG: Import private key'
env:
PGP_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }}
run: |
printf '%s\n' "$PGP_PRIVATE_KEY" | gpg --batch --import
for keygrip in $(gpg --list-secret-keys --with-keygrip "$PGP_KEY_ID" | grep Keygrip | awk '{print $3}'); do
printf '%s\n' "$PGP_PASSPHRASE" | "$(gpgconf --list-dirs libexecdir)/gpg-preset-passphrase" --preset "$keygrip"
done
# Checked before the long build, a problem of the key is found in a few seconds
- name: 'GPG: Check signing'
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }}
run: |
echo "TEST" > ~/test_with_passphrase.txt
echo "TEST" > ~/test_without_passphrase.txt
gpg --batch --yes --passphrase "$PGP_PASSPHRASE" --pinentry-mode loopback --detach-sign --local-user "$PGP_KEY_ID" --output ~/test_with_passphrase.txt.sig ~/test_with_passphrase.txt
gpg --batch --yes --pinentry-mode loopback --detach-sign --local-user "$PGP_KEY_ID" --output ~/test_without_passphrase.txt.sig ~/test_without_passphrase.txt
gpg --batch --verify ~/test_with_passphrase.txt.sig ~/test_with_passphrase.txt
gpg --batch --verify ~/test_without_passphrase.txt.sig ~/test_without_passphrase.txt
- name: Checkout repository
uses: actions/checkout@v7
with:
path: pdf4qt
- name: 'VCPKG: Set up VCPKG'
run: |
# vcpkg is checked out exactly at the builtin-baseline of vcpkg.json. The ABI hashes of the binary
# cache depend also on the scripts and tools of vcpkg, a checkout of its master would change them
# with each commit of vcpkg and all dependencies would be built again.
baseline="$(sed -n 's/.*"builtin-baseline": *"\([0-9a-f]*\)".*/\1/p' pdf4qt/vcpkg.json)"
git init -q vcpkg
git -C vcpkg remote add origin https://github.com/microsoft/vcpkg.git
git -C vcpkg fetch -q --depth=1 origin "$baseline"
git -C vcpkg checkout -q --detach FETCH_HEAD
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
# The key contains the runner image, the compiler differs from the CI build (ubuntu-latest) and the
# binaries of the two builds would push each other out of the cache
- name: 'VCPKG: Restore binary cache'
uses: actions/cache/restore@v6
with:
path: vcpkg-binary-cache
key: vcpkg-bin-v1-ubuntu-22.04-${{ env.VCPKG_TRIPLET }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
vcpkg-bin-v1-ubuntu-22.04-${{ env.VCPKG_TRIPLET }}-
- name: 'VCPKG: Install project dependencies'
run: |
mkdir -p vcpkg-binary-cache
find vcpkg-binary-cache -type f -name '*.zip' | sort > vcpkg-cache-before.txt
# The overlay of libpng avoids the crash of the incompatible libpng on Linux (the general overlays are
# listed in vcpkg-configuration.json)
./vcpkg/vcpkg install --x-manifest-root=pdf4qt --x-install-root="$VCPKG_INSTALLED_DIR" --triplet=$VCPKG_TRIPLET --host-triplet=$VCPKG_TRIPLET --overlay-ports=pdf4qt/vcpkg/overlays/linux --clean-buildtrees-after-build --clean-packages-after-build
- name: 'VCPKG: Prune binary cache'
id: vcpkg-cache
run: |
# The archives of the binary cache are named by the ABI hash of the package. The archives, which were
# not used by this build, are deleted, so the cache does not grow with outdated binaries. The cache is
# saved only when its content has changed.
# The directory updates exists only when the status was not yet compacted into the status file
shopt -s nullglob
{ cat "$VCPKG_INSTALLED_DIR"/vcpkg/status "$VCPKG_INSTALLED_DIR"/vcpkg/updates/* || true; } | tr -d '\r' | sed -n 's/^Abi: *//p' | sort -u > vcpkg-cache-used.txt
if [ -s vcpkg-cache-used.txt ]; then
find vcpkg-binary-cache -type f -name '*.zip' | while read -r archive; do
grep -qxF "$(basename "$archive" .zip)" vcpkg-cache-used.txt || rm -f "$archive"
done
else
echo "::warning::ABI hashes of the installed packages were not found, the binary cache is not pruned"
fi
find vcpkg-binary-cache -type f -name '*.zip' | sort > vcpkg-cache-after.txt
echo "Packages: $(wc -l < vcpkg-cache-after.txt), cache size: $(du -sh vcpkg-binary-cache | cut -f1)"
if cmp -s vcpkg-cache-before.txt vcpkg-cache-after.txt; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
# Saved right after the installation of the dependencies, so a failure of the build does not lose them
- name: 'VCPKG: Save binary cache'
if: steps.vcpkg-cache.outputs.changed == 'true'
uses: actions/cache/save@v6
with:
path: vcpkg-binary-cache
key: vcpkg-bin-v1-ubuntu-22.04-${{ env.VCPKG_TRIPLET }}-${{ github.run_id }}-${{ github.run_attempt }}
# Qt is cached by own steps with the same key as in the CI build (the binaries of Qt do not depend on
# the runner image), the automatic cache of install-qt-action has a long key containing also the kernel
# version of the runner
- name: 'Qt: Cache key'
id: qt-key
run: |
hash="$(printf '%s\n' "$QT_VERSION" "linux" "" "$QT_MODULES" "" | sha256sum | cut -c1-16)"
echo "key=$RUNNER_OS-qt-$QT_VERSION-$hash" >> "$GITHUB_OUTPUT"
- name: 'Qt: Restore cache'
id: qt-cache
uses: actions/cache/restore@v6
with:
path: qt
key: ${{ steps.qt-key.outputs.key }}
- name: 'Qt: Install'
if: steps.qt-cache.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'desktop'
dir: '${{ github.workspace }}/qt/'
modules: ${{ env.QT_MODULES }}
install-deps: 'false'
cache: 'false'
# The environment is set by the step below, the same for an installed and for a restored Qt
set-env: 'false'
- name: 'Qt: Save cache'
if: steps.qt-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: qt
key: ${{ steps.qt-key.outputs.key }}
- name: 'Qt: Set up environment'
run: |
# The same variables as install-qt-action sets
qt_root="$GITHUB_WORKSPACE/qt/Qt/$QT_VERSION/gcc_64"
if [ ! -d "$qt_root/bin" ]; then echo "::error::Qt not found in $qt_root"; exit 1; fi
{
echo "QT_ROOT_DIR=$qt_root"
echo "QT_PLUGIN_PATH=$qt_root/plugins"
echo "QML2_IMPORT_PATH=$qt_root/qml"
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$qt_root/lib"
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}$qt_root/lib/pkgconfig"
} >> "$GITHUB_ENV"
echo "$qt_root/bin" >> "$GITHUB_PATH"
- name: Build project
working-directory: pdf4qt
run: |
# The dependencies are already installed, CMake must not run vcpkg install again into the build tree
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=$VCPKG_TRIPLET -DVCPKG_HOST_TRIPLET=$VCPKG_TRIPLET -DVCPKG_INSTALLED_DIR="$VCPKG_INSTALLED_DIR" -DVCPKG_MANIFEST_INSTALL=OFF -DPDF4QT_INSTALL_QT_DEPENDENCIES=OFF -DPDF4QT_INSTALL_TO_USR=ON
# The package must never contain an unoptimized build
grep -qx 'CMAKE_BUILD_TYPE:STRING=Release' build/CMakeCache.txt || { echo "::error::The build type is not Release"; exit 1; }
cmake --build build --target all release_translations -j6
cmake --install build
- name: Read version
id: version
run: |
version=$(cat "pdf4qt/build/version.txt")
echo "Version: $version"
echo "appimagefilename=PDF4QT-$version-x86_64.AppImage" >> "$GITHUB_ENV"
echo "appimagefilename=PDF4QT-$version-x86_64.AppImage" >> "$GITHUB_OUTPUT"
echo "appimage_update_info=gh-releases-zsync|JakubMelka|PDF4QT|latest|PDF4QT-*-x86_64.AppImage.zsync" >> "$GITHUB_ENV"
echo "AppImage file name: PDF4QT-$version-x86_64.AppImage"
- name: 'Linux Deploy Qt'
working-directory: pdf4qt/build
run: |
cp install/usr/share/icons/hicolor/scalable/apps/io.github.JakubMelka.Pdf4qt.svg install/io.github.JakubMelka.Pdf4qt.svg
wget -q -O deploy.AppImage https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
chmod +x deploy.AppImage
./deploy.AppImage install/usr/share/applications/io.github.JakubMelka.Pdf4qt.desktop -executable-dir=install/usr/bin -bundle-non-qt-libs -extra-plugins=iconengines,imageformats,texttospeech
# .DirIcon (the icon of the AppImage in file managers) must be a PNG, linuxdeployqt makes it from
# the SVG icon of the application
rm -f install/.DirIcon
rsvg-convert -w 256 -h 256 install/io.github.JakubMelka.Pdf4qt.svg -o install/.DirIcon
file install/.DirIcon
- name: Sign and Repack AppImage
working-directory: pdf4qt/build
env:
PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }}
run: |
appimagetool -u "$appimage_update_info" -s --sign-key "$PGP_KEY_ID" install/ "$appimagefilename"
- name: Manual signature
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }}
run: |
gpg --batch --yes --pinentry-mode loopback --detach-sign --passphrase "$PGP_PASSPHRASE" --local-user "$PGP_KEY_ID" --output "pdf4qt/build/$appimagefilename.sig" "pdf4qt/build/$appimagefilename"
- name: Verify AppImage Detached Signature
env:
PGP_PUBLIC_KEY: ${{ secrets.PGP_PUBLIC_KEY }}
run: |
printf '%s\n' "$PGP_PUBLIC_KEY" | gpg --batch --import
gpg --verify "pdf4qt/build/$appimagefilename.sig" "pdf4qt/build/$appimagefilename"
# The attested files are the files of the release (Create_Release_Draft takes them unchanged)
# The transparency log of Sigstore fails sometimes (HTTP 500), the attestation is tried once more
- name: Attest AppImage
id: attest
continue-on-error: true
uses: actions/attest@v4
with:
subject-path: |
${{ github.workspace }}/pdf4qt/build/${{ steps.version.outputs.appimagefilename }}
${{ github.workspace }}/pdf4qt/build/${{ steps.version.outputs.appimagefilename }}.sig
${{ github.workspace }}/pdf4qt/build/${{ steps.version.outputs.appimagefilename }}.zsync
- name: Attest AppImage (wait before the retry)
if: steps.attest.outcome == 'failure'
run: sleep 60
- name: Attest AppImage (retry)
if: steps.attest.outcome == 'failure'
uses: actions/attest@v4
with:
subject-path: |
${{ github.workspace }}/pdf4qt/build/${{ steps.version.outputs.appimagefilename }}
${{ github.workspace }}/pdf4qt/build/${{ steps.version.outputs.appimagefilename }}.sig
${{ github.workspace }}/pdf4qt/build/${{ steps.version.outputs.appimagefilename }}.zsync
- name: Upload AppImage Package
uses: actions/upload-artifact@v7
with:
name: ${{ steps.version.outputs.appimagefilename }}
path: ./pdf4qt/build/${{ steps.version.outputs.appimagefilename }}
retention-days: 7
compression-level: 0
- name: Upload AppImage Signature File
uses: actions/upload-artifact@v7
with:
name: ${{ steps.version.outputs.appimagefilename }}.sig
path: ./pdf4qt/build/${{ steps.version.outputs.appimagefilename }}.sig
retention-days: 7
if-no-files-found: warn
compression-level: 0
- name: Upload AppImage zsync File
uses: actions/upload-artifact@v7
with:
name: ${{ steps.version.outputs.appimagefilename }}.zsync
path: ./pdf4qt/build/${{ steps.version.outputs.appimagefilename }}.zsync
retention-days: 7
if-no-files-found: warn
compression-level: 0
- name: Cleanup GPG home
if: always()
run: |
rm -rf "$GNUPGHOME"