-
Notifications
You must be signed in to change notification settings - Fork 12
289 lines (260 loc) · 9.67 KB
/
build_and_release.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
name: Build / Release
on:
pull_request:
push:
branches: [ 'main' ]
tags: [ '*' ]
workflow_dispatch:
jobs:
build:
name: ${{ matrix.job.name }}
runs-on: ${{ matrix.job.runner }}
strategy:
fail-fast: false
matrix:
job:
- name: Ubuntu 22.04 amd64
runner: ubuntu-22.04
target: ubuntu22.04-amd64
- name: Ubuntu 22.04 arm64
runner: ubuntu-22.04-arm
target: ubuntu22.04-arm64
- name: Windows x86
runner: windows-latest
target: win32
qt_arch: win32_msvc2019
qt_version: 5.15.2
qt_archives: d3dcompiler_47 opengl32sw qtbase qtlocation qtmultimedia qttools qttranslations qtwebchannel qtdeclarative
qt_modules: qtwebengine
cmake_args: -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DQOLIBRI_QT5=ON
win_arch: x86
- name: Windows x64
runner: windows-latest
target: win64
qt_arch: win64_msvc2022_64
qt_version: 6.8.1
qt_archives: d3dcompiler_47 opengl32sw qtbase qtdeclarative qttools qttranslations
qt_modules: qt5compat qtmultimedia qtpositioning qtwebchannel qtwebengine
cmake_args: -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl
win_arch: x64
- name: macOS 10.13
runner: macos-latest
target: macos10.13
qt_arch: clang_64
qt_version: 5.15.2
qt_archives: qtwebchannel qttranslations qttools qtmultimedia qtlocation qtdeclarative qtbase
qt_modules: qtwebengine
cmake_args: -DCMAKE_OSX_ARCHITECTURES='x86_64' -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 -DQOLIBRI_QT5=ON
macos_dmg_format: ULFO
- name: macOS 11 ARM
runner: macos-latest
target: macos11-arm
qt_arch: clang_64
qt_version: 6.8.1
qt_archives: qttranslations qttools qtdeclarative qtbase
qt_modules: qtmultimedia qtpositioning qtwebchannel qtwebengine qt5compat
cmake_args: -DCMAKE_OSX_ARCHITECTURES='arm64'
macos_dmg_format: ULMO
macos11_arch: arm64
- name: macOS 11 Intel
runner: macos-latest
target: macos11-intel
qt_arch: clang_64
qt_version: 6.8.1
qt_archives: qttranslations qttools qtdeclarative qtbase
qt_modules: qtmultimedia qtpositioning qtwebchannel qtwebengine qt5compat
cmake_args: -DCMAKE_OSX_ARCHITECTURES='x86_64'
macos_dmg_format: ULMO
macos11_arch: x86_64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Populate environment
id: env
run: |
if [ "$GITHUB_REF_TYPE" = tag ]; then
echo "version=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
else
rev=${GITHUB_SHA::${#GITHUB_SHA}-33}
ver=$(grep '^project(.* VERSION' CMakeLists.txt)
ver=${ver##* }
ver=${ver%)}
echo "version=$ver+g$rev" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: Install dependencies (Ubuntu)
if: ${{ startsWith(matrix.job.runner, 'ubuntu') }}
run: |
set -ex
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
debhelper \
fakeroot \
libeb16-dev \
ninja-build \
zlib1g-dev \
\
qt5-qmake \
qtmultimedia5-dev \
qttools5-dev \
qtwebengine5-dev \
\
libqt6core5compat6-dev \
libqt6opengl6-dev \
qt6-declarative-dev \
qt6-l10n-tools \
qt6-multimedia-dev \
qt6-tools-dev \
qt6-tools-dev-tools \
qt6-webengine-dev \
qt6-webengine-dev-tools
- name: Install Qt (Windows, macOS)
uses: jurplel/install-qt-action@v4
if: ${{ matrix.job.qt_version }}
with:
arch: ${{ matrix.job.qt_arch }}
version: ${{ matrix.job.qt_version }}
archives: ${{ matrix.job.qt_archives }}
modules: ${{ matrix.job.qt_modules }}
- name: Install Ninja (Windows)
if: ${{ startsWith(matrix.job.runner, 'windows') }}
run: |
if ((Get-Command "ninja.exe" -ErrorAction SilentlyContinue) -eq $null)
{
choco install ninja
}
- name: Install Ninja (macOS)
if: ${{ startsWith(matrix.job.runner, 'macos') }}
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install ninja
- name: Set up MSVC environment (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.job.win_arch }}
with:
arch: ${{ matrix.job.win_arch }}
- name: Configure (Windows, macOS)
if: ${{ !startsWith(matrix.job.runner, 'ubuntu') }}
run: >
cmake -B build -G Ninja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=build
-DQOLIBRI_VERSION_STR="${{ steps.env.outputs.version }}"
${{ matrix.job.cmake_args }}
- name: Build Qt5 (Ubuntu)
if: ${{ startsWith(matrix.job.runner, 'ubuntu') }}
run: |
set -ex
export BUILD_DIR="build/qt5"
export INSTALL_DIR="qolibri_${{ steps.env.outputs.version }}_${{ matrix.job.target }}_qt5"
cmake -B "$BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="build/$INSTALL_DIR" -DQOLIBRI_VERSION_STR='${{ steps.env.outputs.version }}' -DQOLIBRI_QT5=ON
cmake --build "$BUILD_DIR"
cmake --install "$BUILD_DIR" --strip
mkdir -p build/bin
tar -C build -cJf build/bin/"$INSTALL_DIR".tar.xz "$INSTALL_DIR"
- name: Build Qt6 (Ubuntu)
if: ${{ startsWith(matrix.job.runner, 'ubuntu') }}
run: |
set -ex
export BUILD_DIR="build/qt6"
export INSTALL_DIR="qolibri_${{ steps.env.outputs.version }}_${{ matrix.job.target }}_qt6"
cmake -B "$BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="build/$INSTALL_DIR" -DQOLIBRI_VERSION_STR='${{ steps.env.outputs.version }}'
cmake --build "$BUILD_DIR"
cmake --install "$BUILD_DIR" --strip
mkdir -p build/bin
tar -C build -cJf build/bin/"$INSTALL_DIR".tar.xz "$INSTALL_DIR"
- name: Build .deb package (Ubuntu)
if: ${{ startsWith(matrix.job.runner, 'ubuntu') }}
run: |
set -ex
if [ "$GITHUB_REF_TYPE" != tag ]; then
mv debian/changelog debian/changelog.old
{
echo "qolibri (${{ steps.env.outputs.version }}) UNRELEASED; urgency=low
* $(git show -s --format='%s')
-- $(git show -s --format='%an <%ae>') $(date -R)
"
cat debian/changelog.old
} > debian/changelog
sed -i '/dh_auto_configure --/ s/$/ -DQOLIBRI_VERSION_STR="${{ steps.env.outputs.version }}"/' debian/rules
fi
dpkg-buildpackage
mkdir -p build/bin
mv ../*.deb build/bin/
- name: Build (Windows, macOS)
if: ${{ !startsWith(matrix.job.runner, 'ubuntu') }}
run: |
cmake --build build
- name: Deploy (Windows)
if: ${{ startsWith(matrix.job.runner, 'windows') }}
run: |
set name=qolibri_${{ steps.env.outputs.version }}_${{ matrix.job.target }}
cd build
md "%name%" bin
move qolibri.exe "%name%"
windeployqt --release "%name%"
7z a -mx9 "%name%.7z" "%name%"
move "%name%.7z" bin
shell: cmd
- name: Deploy (macOS)
if: ${{ startsWith(matrix.job.runner, 'macos') }}
run: |
set -ex
volname='qolibri_${{ steps.env.outputs.version }}_${{ matrix.job.target }}'
cd build
macdeployqt qolibri.app
mkdir bin
mv qolibri.app bin/
if [ '${{ matrix.job.macos11_arch }}' ]; then
arch='${{ matrix.job.macos11_arch }}'
for file in $(find bin/ -type f); do
file -b "$file" | grep -q '^Mach-O universal binary ' || continue
lipo -thin "$arch" -output "$file.$arch" "$file"
mv "$file.$arch" "$file"
done
fi
# https://github.com/actions/runner-images/issues/7522
try=1
until hdiutil create -srcfolder bin -volname "$volname" -format ${{ matrix.job.macos_dmg_format }} "$volname".dmg
do
if [ "$try" -eq 10 ]; then
echo "Error: hdiutil failed after $try tries"
exit 1
fi
try=$((try + 1))
sleep 2
done
mv bin/qolibri.app .
mv "$volname".dmg bin/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: qolibri_${{ steps.env.outputs.version }}_${{ matrix.job.target }}
if-no-files-found: error
compression-level: 0
path: |
build/bin/
release:
name: Release (tags only)
if: github.ref_type == 'tag'
needs: build
permissions:
actions: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: List artifacts
run: ls -laR
- name: Create release
uses: softprops/action-gh-release@v2
with:
draft: true
files: qolibri_*