-
-
Notifications
You must be signed in to change notification settings - Fork 113
427 lines (363 loc) · 14.6 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
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
# https://docs.github.com/en/actions/learn-github-actions/contexts
---
name: Gittyup
on:
push:
branches:
- master
tags:
- 'gittyup_v*'
pull_request:
page_build:
workflow_dispatch:
env:
IS_RELEASE: ${{ github.event_name == 'push' && github.ref_type == 'tag' && startswith(github.ref_name, 'gittyup_v') }}
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '13'
exclude-regex: 'dep'
- name: Check CMake code style
run: |
pip install cmake-format==0.6.13 && \
find \( -type d -path './dep/*/*' -prune \) -o \( -name CMakeLists.txt -exec cmake-format --check {} + \)
flatpak:
name: "Flatpak"
runs-on: ubuntu-latest
container:
# image: bilelmoussaoui/flatpak-github-actions:kde-5.15-21.08
image: archlinux:latest
options: --privileged
steps:
- name: Update
run: |
pacman --noconfirm -Suy
pacman --noconfirm -S flatpak flatpak-builder xorg-server-xvfb
flatpak install --assumeyes org.freedesktop.Sdk.Extension.golang//23.08
- name: Show environment variables
run: >
echo IS_RELEASE: ${{ env.IS_RELEASE }}
# https://stackoverflow.com/questions/60916931/github-action-does-the-if-have-an-else
- name: Determine flatpak release branch
uses: haya14busa/action-cond@v1
id: flatpak_release_branch
with:
cond: ${{ env.IS_RELEASE }}
if_true: 'stable'
if_false: 'development'
- name: Checkout repository
uses: actions/checkout@v3
- name: Replace git tag by the commit id on which it runs
if: github.ref_type != 'tag'
run: >
sed -i 's@tag: .*@commit: "${{ (github.event.pull_request && github.event.pull_request.head.sha) || github.sha }}"@' com.github.Murmele.Gittyup.yml
- name: Use correct git tag
if: github.ref_type == 'tag'
run: >
sed -i 's@tag: .*$@tag: "${{ github.ref_name }}"@' com.github.Murmele.Gittyup.yml
- name: Replace source url
run: >
sed -i "s@url: .*Gittyup.git@url: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY@" com.github.Murmele.Gittyup.yml
- name: Add dev build marker to cmake options
if: github.ref_type != 'tag'
run: >
sed -i 's@config-opts: \["\(.*\)"\]@config-opts: ["\1", "-DDEV_BUILD=${{ github.ref_name }}"]@' com.github.Murmele.Gittyup.yml
- name: Replace desktop file name suffix
if: github.ref_type != 'tag'
run: >
sed -i 's@desktop-file-name-suffix: ""@desktop-file-name-suffix: " (Development)"@' com.github.Murmele.Gittyup.yml
- name: Enable automatic update
if: github.ref_type != 'tag'
run: >
sed -i 's@-DENABLE_UPDATE_OVER_GUI=OFF@-DENABLE_UPDATE_OVER_GUI=ON@' com.github.Murmele.Gittyup.yml
- name: Show Flatpak manifest
run: cat com.github.Murmele.Gittyup.yml
- name: Build package
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v6
with:
bundle: Gittyup.flatpak
manifest-path: com.github.Murmele.Gittyup.yml
cache: false
upload-artifact: true
verbose: true
branch: ${{ steps.flatpak_release_branch.outputs.value }}
- name: Publish build artifacts
uses: actions/upload-artifact@v4
with:
path: Gittyup.flatpak
name: GittyupFlatpak
build:
runs-on: ${{ matrix.env.os }}
strategy:
fail-fast: false
matrix:
qt:
- version: 5.15.2
check_only: false
- version: 5.12.0
check_only: true
env:
- name: linux
os: ubuntu-latest
ninja_platform: linux
qt_platform: linux
qt_arch: gcc_64
openssl_arch: linux-x86_64
ld_library_arch: linux-x86-64
cmake_flags: "-DGENERATE_APPDATA=ON -DCMAKE_INSTALL_PREFIX=/usr -DUSE_SYSTEM_QT=ON -DENABLE_UPDATE_OVER_GUI=OFF -DUSE_SSH=ON -DUSE_SYSTEM_LIBSSH2=ON -DUSE_SYSTEM_OPENSSL=ON"
pack: 0
cmake_env: {}
- name: macos
os: macos-12
ninja_platform: mac
qt_platform: mac
openssl_arch: darwin64-x86_64-cc
cmake_flags: "-DUSE_SSH:STRING=localbuild"
cmake_env: {}
pack: 1
- name: win64
os: windows-latest
ninja_platform: win
qt_platform: windows
qt_arch: win64_msvc2019_64
qt_arch_check_only: win64_msvc2017_64
openssl_arch: VC-WIN64A
msvc_arch: x64
cmake_flags: "-DUSE_SSH:STRING=localbuild"
cmake_env:
CMAKE_RC_FLAGS: "/C 1252"
CC: clang
CXX: clang++
pack: 1
steps:
# otherwise the testcases will fail, because signature is invalid
- name: Set git name and email
run: |
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --list
- name: Configure development build
if: github.ref_type != 'tag'
uses: allenevans/set-env@c4f231179ef63887be707202a295d9cb1c687eb9
with:
CMAKE_FLAGS: '-DDEV_BUILD="${{ github.ref_name }}"'
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize Submodules
uses: snickerbockers/submodules-init@v4
- name: Install Perl
if: matrix.env.ninja_platform == 'win'
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.30'
- name: Install Libssh2
if: matrix.env.ninja_platform == 'linux'
run: |
sudo apt-get update
sudo apt-get -y install libssh2-1
sudo apt-get -y install libssh2-1-dev
- name: Install Qt
uses: jurplel/[email protected]
timeout-minutes: 10
if: "!matrix.qt.check_only"
with:
version: ${{ matrix.qt.version }}
target: desktop
host: ${{ matrix.env.qt_platform }}
arch: ${{ matrix.env.qt_arch }}
install-deps: true
modules: qtwebengine
- name: Install Qt
uses: jurplel/[email protected]
timeout-minutes: 10
if: matrix.qt.check_only
with:
version: ${{ matrix.qt.version }}
target: desktop
host: ${{ matrix.env.qt_platform }}
arch: ${{ matrix.env.qt_arch_check_only }}
install-deps: true
modules: qtwebengine
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@v4
with:
version: 1.11.1
platform: ${{ matrix.env.ninja_platform }}
destination: ninja
- name: Setup MSVC environment
if: matrix.env.ninja_platform == 'win'
uses: seanmiddleditch/gha-setup-vsdevenv@v3
with:
arch: ${{ matrix.env.msvc_arch }}
- name: Install NASM
if: matrix.env.ninja_platform == 'win'
uses: ilammy/[email protected]
#- name: Build OpenSSL (Linux)
# if: matrix.env.ninja_platform == 'linux'
# run: |
# cd dep/openssl/openssl
# ./config -fPIC
# make
- name: Build OpenSSL (macOS)
if: matrix.env.ninja_platform == 'mac'
run: |
cd dep/openssl/openssl
# this is necessary until https://github.com/openssl/openssl/issues/18720
# is fixed in OpenSSL 1.1.1r
export CFLAGS=-Wno-error=implicit-function-declaration
./Configure ${{ matrix.env.openssl_arch }} no-shared
make
- name: Build OpenSSL (Windows)
if: matrix.env.ninja_platform == 'win'
run: |
cd dep/openssl/openssl
perl Configure ${{ matrix.env.openssl_arch }}
nmake
- name: Configure Release
env: ${{ matrix.env.cmake_env }}
run: |
mkdir -p build/release
cd build/release
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DUPDATE_TRANSLATIONS=ON -DGITTYUP_CI_TESTS=ON ${{ env.CMAKE_FLAGS }} ${{ matrix.env.cmake_flags }} ../..
- name: Build Information
run: |
echo "ninja version: $(ninja --version)"
git --version
qmake --version
cmake --version
- name: Build
run: |
cd build/release
ninja package
# Command copied from flathub build process
- name: Validate appdata file
if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only
run: |
echo "Show generated appdata file"
cat ./build/release/rsrc/linux/com.github.Murmele.Gittyup.appdata.xml
echo "Start validating appdata file"
sudo apt install flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak install -y org.freedesktop.appstream-glib
flatpak run --env=G_DEBUG=fatal-criticals org.freedesktop.appstream-glib validate ./build/release/rsrc/linux/com.github.Murmele.Gittyup.appdata.xml
- name: Publish build artifacts
if: matrix.env.pack && !matrix.qt.check_only
uses: actions/upload-artifact@v4
with:
path: build/release/pack/Gittyup-*
name: Gittyup ${{ matrix.env.name }}
# Publish only once!
- name: Publish version file
if: matrix.env.pack && !matrix.qt.check_only && matrix.env.name == 'win64'
uses: actions/upload-artifact@v4
with:
path: build/release/Version.txt
name: Gittyup-VERSION
- name: Check Version file
run: |
cd build/release
cat ./Version.txt
- name: Test
if: matrix.env.ninja_platform != 'win' && matrix.env.ninja_platform != 'mac'
uses: GabrielBB/xvfb-action@v1
with:
working-directory: build/release
run: ninja check --verbose
- name: Test (Windows)
if: matrix.env.ninja_platform == 'win'
run: |
cd build/release
ninja check_no_win32_offscreen
- name: Build Appimage
if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only
run: |
cd build/release
sudo apt -y install appstream
sudo apt -y install libfuse2
sudo apt -y install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0
sudo apt -y install libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxcb-xrm0 libxcb-xv0 libxcb-xvmc0 libxcb1
mkdir -p AppDir
DESTDIR=AppDir ninja install
export QTDIR=$RUNNER_WORKSPACE/Qt/${{ matrix.qt.version }}/${{ matrix.env.qt_arch }}
rm -rf ./AppDir/usr/include/
strip ./AppDir/usr/bin/cmark ./AppDir/usr/bin/gittyup ./AppDir/usr/bin/indexer ./AppDir/usr/bin/relauncher
wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases/expanded_assets/continuous -O - | grep "appimagetool-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2)
chmod +x appimagetool-*.AppImage
QTDIR=$QTDIR ./appimagetool-*.AppImage -s deploy ./AppDir/usr/share/applications/*.desktop --appimage-extract-and-run # Bundle EVERYTHING
# Modify the AppDir: move ld-linux into the same directory as the payload application
# and change AppRun accordingly; so that, e.g., Qt qApp->applicationDirPath() works
mv ./AppDir/lib64/ld-${{ matrix.env.ld_library_arch }}.so.2 ./AppDir/usr/bin/
sed -i -e 's@^LD_LINUX.*@LD_LINUX=$(find "$HERE/usr/bin" -name "ld-*.so.*" | head -n 1)@g' ./AppDir/AppRun
rm ./AppDir/usr/share/metainfo/gittyup.appdata.xml
VERSION=$(cat ./Version.txt)
VERSION="$VERSION" ./appimagetool-*.AppImage ./AppDir # turn AppDir into AppImage
#ls -lh Gittyup-*
- name: Publish Appimage
if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only
uses: actions/upload-artifact@v4
with:
path: build/release/*.AppImage
name: GittyupAppImage
publish:
# https://github.com/marvinpinto/actions/issues/177
needs: [flatpak, build]
runs-on: ubuntu-latest # does not matter which
# a prerelase is created when pushing to master
# a release is created when a tag will be set
# last condition is the same as IS_RELEASE,
# but environment variables cannot be used outside of steps
# so it was copied to here too
if: ${{ github.ref == 'refs/heads/master' || (github.event_name == 'push' && github.ref_type == 'tag' && startswith(github.ref_name, 'gittyup_v')) }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
# version is exported from cmake to file
- name: Retrieve version
run: |
echo "::set-output name=VERSION::$(cat artifacts/Gittyup-VERSION/Version.txt)"
id: version
- name: Update GitHub release (latest tag)
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
title: 'Latest Build (Development)'
automatic_release_tag: 'development'
files: |
**/artifacts/Gittyup win64/Gittyup*.exe
**/artifacts/Gittyup macos/Gittyup*.dmg
**/artifacts/GittyupFlatpak/*.flatpak
**/artifacts/GittyupAppImage/Gittyup*.AppImage
- name: Update GitHub release (version tag)
uses: marvinpinto/action-automatic-releases@latest
if: ${{ env.IS_RELEASE == 'true'}}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
title: Gittyup Release ${{ steps.version.outputs.VERSION }}
automatic_release_tag: ${{ github.ref_name }}
files: |
**/artifacts/Gittyup win64/Gittyup*.exe
**/artifacts/Gittyup macos/Gittyup*.dmg
**/artifacts/GittyupFlatpak/*.flatpak
**/artifacts/GittyupAppImage/Gittyup*.AppImage
# needed otherwise the docs folder is not available
- name: Checkout repository
if: ${{ env.IS_RELEASE == 'true'}}
uses: actions/checkout@v3
# update github pages only if it is a release
- name: Deploy Github pages
if: ${{ env.IS_RELEASE == 'true'}}
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs # The folder the action should deploy.
...