-
Notifications
You must be signed in to change notification settings - Fork 2
278 lines (259 loc) · 9.72 KB
/
cmake.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
name: CMake Build
on:
# push代码时触发workflow
push:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/qmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
- 'doc/**'
- 'translation/**'
- '.clang-*'
- '.gitignore'
- 'LICENSE'
- 'README*'
pull_request:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/qmake.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
- 'doc/**'
- 'translation/**'
- '.clang-*'
- '.gitignore'
- 'LICENSE'
- 'README*'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- macos-latest
- ubuntu-latest
qt_ver:
- 6.7.0
qt_modules:
- qt5compat qtserialport qtnetworkauth qtmultimedia qtimageformats
build_type:
- "RelWithDebInfo"
generators:
- "Ninja"
arch:
- x86_64
vcpkg_libs:
- breakpad
include:
- os: macos-latest
qt_ver: 6.7.0
qt_modules: qt5compat qtserialport qtnetworkauth qtmultimedia qtimageformats
build_type: "RelWithDebInfo"
generators: "Ninja"
arch: arm64
vcpkg_libs: breakpad
steps:
- name: Set macos deployment target
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
- name: Restore windows vcpkg
if: startsWith(matrix.os, 'windows')
uses: actions/cache/restore@v4
with:
path: C:\vcpkg\installed
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}
- name: Restore macos or ubuntu vcpkg
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
uses: actions/cache/restore@v4
with:
path: /usr/local/share/vcpkg/installed
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}
- name: Install dependencies on windows
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
choco install ninja
ninja --version
cmake --version
vcpkg install ${{ matrix.vcpkg_libs }} --triplet x64-windows || (cat ./build/vcpkg_installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on ubuntu
if: startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
sudo apt-get update
sudo apt-get install ninja-build build-essential libgl1-mesa-dev
ninja --version
cmake --version
gcc --version
vcpkg install ${{ matrix.vcpkg_libs }} --triplet x64-linux || (cat ./build/vcpkg_installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on macos-x86_64
if: startsWith(matrix.os, 'macos') && matrix.arch == 'x86_64'
shell: bash
run: |
brew install ninja pkg-config
ninja --version
cmake --version
clang --version
vcpkg install ${{ matrix.vcpkg_libs }} --triplet x64-osx || (cat ./build/vcpkg_installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on macos-arm64
if: startsWith(matrix.os, 'macos') && matrix.arch == 'arm64'
shell: bash
run: |
brew install ninja pkg-config
ninja --version
cmake --version
clang --version
vcpkg install ${{ matrix.vcpkg_libs }} --triplet arm64-osx || (cat ./build/vcpkg_installed/vcpkg/issue_body.md && exit 1)
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
install-deps: 'true'
modules: '${{ matrix.qt_modules }}'
cache: 'true'
- uses: actions/checkout@v4
with:
fetch-depth: 1
# jurplel/install-qt-action@v3, 这个action会修改默认的python版本,
# 会导致部分使用vcpkg的库编译失败,比如libsystemd,所以需要删除vcpkg.json
- name: Delete vcpkg.json
shell: bash
run: |
rm vcpkg.json
- name: Configure msvc for amd64
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- name: Configure windows
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
cmake \
-S . \
-B ./build \
-DCMAKE_C_COMPILER=cl \
-DCMAKE_CXX_COMPILER=cl \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-G "${{ matrix.generators }}" \
-DCMAKE_INSTALL_PREFIX:PATH=instdir
- name: Configure macos or ubuntu
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
cmake \
-S . \
-B ./build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" \
-G "${{ matrix.generators }}" \
-DCMAKE_INSTALL_PREFIX:PATH=instdir
- name: Build
shell: bash
run: |
cmake --build ./build --config ${{ matrix.build_type }}
- name: Deploy Windows
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
cd ./bin-64/${{ matrix.build_type }}
# deploy contains plugins
cp -rf ./plugins/* .
files=$(find . -maxdepth 1 -type f -printf '%P\n')
for file in $files;
do
if [[ $file == *.exe || $file == *.dll ]]; then
windeployqt --force --compiler-runtime $file
fi
done
rm -rf *plugin.dll
ls -l
- name: Deploy macos
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
macdeployqt ./bin-64/${{ matrix.build_type }}/Qt-App.app -always-overwrite
ls -l ./bin-64/${{ matrix.build_type }}/Qt-App.app/Contents/Frameworks
rm -rf ./bin-64/${{ matrix.build_type }}/plugins
rm -f ./bin-64/${{ matrix.build_type }}/CrashReport
rm -f ./bin-64/${{ matrix.build_type }}/*.dylib
# make dmg
pip3 install dmgbuild
dmgbuild -s ./packaging/macos/Qt-App.dmgbuild.py "Qt-App" ./bin-64/${{ matrix.build_type }}/Qt-App.dmg
- name: Deploy ubuntu
if: startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
sudo add-apt-repository universe
sudo apt update
sudo apt install libfuse2 libxcb-cursor0
wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
cp -f ./packaging/ubuntu/Qt-App.desktop ./bin-64/${{ matrix.build_type }}/Qt-App.desktop
cp -f ./src/resource/icon/app.png ./bin-64/${{ matrix.build_type }}/app.png
cp -f ./bin-64/${{ matrix.build_type }}/plugins/* ./bin-64/${{ matrix.build_type }}
so_files=$(find ./bin-64/${{ matrix.build_type }} -maxdepth 1 -name "*.so" -printf '%P\n')
for so_file in $so_files;
do
./linuxdeployqt-continuous-x86_64.AppImage \
./bin-64/${{ matrix.build_type }}/$so_file \
-qmake=${{ env.Qt6_DIR }}/bin/qmake \
-always-overwrite -unsupported-allow-new-glibc
done
rm -f ./bin-64/${{ matrix.build_type }}/AppRun
./linuxdeployqt-continuous-x86_64.AppImage \
./bin-64/${{ matrix.build_type }}/Qt-App \
-executable=./bin-64/${{ matrix.build_type }}/CrashReport \
-qmake=${{ env.Qt6_DIR }}/bin/qmake \
-always-overwrite -unsupported-allow-new-glibc \
-appimage
rm linuxdeployqt-continuous-x86_64.AppImage
rm -f ./bin-64/${{ matrix.build_type }}/*.so
mv *.AppImage ./bin-64/${{ matrix.build_type }}
- name: 7z package
shell: bash
run: |
ls -al ./bin-64/${{ matrix.build_type }}
7z a -t7z -r -mx=9 -mmt Qt-App-${{ matrix.os }}-${{matrix.arch}}-${{ matrix.build_type }}.7z ./bin-64/${{ matrix.build_type }}/*
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{matrix.arch}}-${{ matrix.build_type }}
path: Qt-App-${{ matrix.os }}-${{matrix.arch}}-${{ matrix.build_type }}.7z
release:
name: Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download fonts
shell: bash
run: |
wget -c -nv "https://github.com/RealChuan/Qt-App/releases/download/0.0.1/fonts.7z"
- name: Download packages
uses: actions/download-artifact@v3
- name: Move packages
shell: bash
run: |
ls -al
mv ./windows-latest-x86_64-RelWithDebInfo/Qt-App-*.7z .
mv ./ubuntu-latest-x86_64-RelWithDebInfo/Qt-App-*.7z .
mv ./macos-latest-x86_64-RelWithDebInfo/Qt-App-*.7z .
mv ./macos-latest-arm64-RelWithDebInfo/Qt-App-*.7z .
ls -al
- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
generate_release_notes: true
files: |
*.7z