-
Notifications
You must be signed in to change notification settings - Fork 1
209 lines (186 loc) · 7.49 KB
/
Copy pathrelease.yml
File metadata and controls
209 lines (186 loc) · 7.49 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
package:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows / MSVC
os: windows-latest
asset: windows-x64
- name: Linux / GCC
os: ubuntu-latest
asset: linux-x64
- name: macOS / Clang
os: macos-15
asset: macos
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Linux packages
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libgl1-mesa-dev libxcb-cursor0 libxkbcommon-x11-0
- name: Install macOS packages
if: runner.os == 'macOS'
run: brew install ninja
- name: Setup MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.8.0'
modules: 'qtserialport qt5compat'
cache: true
- name: Configure
shell: pwsh
run: |
$qtPrefix = $env:QT_ROOT_DIR
if (-not $qtPrefix -and $env:Qt6_DIR) {
$qtPrefix = (Resolve-Path (Join-Path $env:Qt6_DIR "../../..")).Path
}
if (-not $qtPrefix) {
throw "Qt prefix was not found."
}
$buildType = if ($env:RUNNER_OS -eq "Windows") { "MinSizeRel" } else { "Release" }
cmake -S . -B build/release -G Ninja -DCMAKE_BUILD_TYPE="$buildType" -DCMAKE_PREFIX_PATH="$qtPrefix"
- name: Build
run: cmake --build build/release --parallel
- name: Package
shell: bash
run: |
set -euo pipefail
mkdir -p artifacts
release_name="FluentSerialAssistant-${GITHUB_REF_NAME}-${{ matrix.asset }}"
package_root="${RUNNER_TEMP}/${release_name}"
rm -rf "$package_root"
mkdir -p "$package_root"
if [ "${{ runner.os }}" = "Windows" ]; then
binary_target="$(find build/release -maxdepth 6 -type f -name 'FluentSerialAssistant.exe' | head -n 1 || true)"
if [ -z "$binary_target" ]; then
echo "Unable to locate Windows executable."
find build/release -maxdepth 6 -print
exit 1
fi
cp "$binary_target" "$package_root/"
windeployqt \
--release \
--no-translations \
--no-system-d3d-compiler \
--no-system-dxc-compiler \
--no-compiler-runtime \
--no-opengl-sw \
--no-ffmpeg \
--skip-plugin-types generic,tls,networkinformation,styles \
--exclude-plugins qgif,qjpeg,qico \
"$package_root/FluentSerialAssistant.exe"
rm -f "$package_root"/vc_redist.*.exe
elif [ "${{ runner.os }}" = "macOS" ]; then
app_target="$(find build/release -maxdepth 6 -type d -name 'FluentSerialAssistant.app' | head -n 1 || true)"
if [ -z "$app_target" ]; then
echo "Unable to locate macOS app bundle."
find build/release -maxdepth 6 -print
exit 1
fi
cp -R "$app_target" "$package_root/"
macdeployqt "$package_root/FluentSerialAssistant.app"
else
binary_target="$(find build/release -maxdepth 6 -type f -name 'FluentSerialAssistant' | head -n 1 || true)"
if [ -z "$binary_target" ]; then
echo "Unable to locate Linux executable."
find build/release -maxdepth 6 -print
exit 1
fi
mkdir -p "$package_root/bin" "$package_root/lib" "$package_root/plugins"
cp "$binary_target" "$package_root/bin/FluentSerialAssistant"
chmod +x "$package_root/bin/FluentSerialAssistant"
qt_prefix="${QT_ROOT_DIR:-}"
if [ -z "$qt_prefix" ]; then
qt_prefix="$(qtpaths6 --install-prefix 2>/dev/null || qtpaths --install-prefix)"
fi
qt_plugins_dir="$(qtpaths6 --plugin-dir 2>/dev/null || qtpaths --plugin-dir)"
copy_qt_dependencies() {
local source_file="$1"
while IFS= read -r dep; do
if [ -z "$dep" ] || [ ! -f "$dep" ]; then
continue
fi
case "$dep" in
"$qt_prefix"/*)
copy_qt_library "$dep"
;;
esac
done < <(ldd "$source_file" | awk '{ if ($2 == "=>") print $3; else if ($1 ~ /^\//) print $1; }')
}
copy_qt_library() {
local dep="$1"
local base
base="$(basename "$dep")"
if [ -f "$package_root/lib/$base" ]; then
return
fi
cp -Lf "$dep" "$package_root/lib/$base"
copy_qt_dependencies "$dep"
}
copy_qt_plugin_group() {
local group="$1"
shift
local destination="$package_root/plugins/$group"
mkdir -p "$destination"
local pattern plugin
for pattern in "$@"; do
for plugin in "$qt_plugins_dir/$group"/$pattern; do
if [ ! -e "$plugin" ]; then
continue
fi
cp -Lf "$plugin" "$destination/"
copy_qt_dependencies "$plugin"
done
done
}
copy_qt_dependencies "$package_root/bin/FluentSerialAssistant"
copy_qt_plugin_group platforms 'libqxcb.so'
copy_qt_plugin_group imageformats '*.so'
copy_qt_plugin_group iconengines '*.so'
copy_qt_plugin_group tls '*.so'
copy_qt_plugin_group platforminputcontexts '*.so'
printf '%s\n' '[Paths]' 'Prefix = ..' 'Plugins = ../plugins' > "$package_root/bin/qt.conf"
printf '%s\n' \
'#!/usr/bin/env bash' \
'set -e' \
'app_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"' \
'export LD_LIBRARY_PATH="$app_dir/lib:${LD_LIBRARY_PATH:-}"' \
'export QT_PLUGIN_PATH="$app_dir/plugins"' \
'exec "$app_dir/bin/FluentSerialAssistant" "$@"' \
> "$package_root/FluentSerialAssistant"
chmod +x "$package_root/FluentSerialAssistant"
mkdir -p "$package_root/share/applications" "$package_root/share/icons/hicolor/1024x1024/apps"
cp packaging/linux/tech.zhangshu.FluentSerialAssistant.desktop "$package_root/share/applications/"
cp logo.png "$package_root/share/icons/hicolor/1024x1024/apps/tech.zhangshu.FluentSerialAssistant.png"
du -sh "$package_root"
fi
cp README.md CHANGELOG.md LICENSE "$package_root/"
if [ "${{ runner.os }}" = "Windows" ] && command -v 7z >/dev/null 2>&1; then
7z a "artifacts/${release_name}.zip" "$package_root/."
else
tar -czf "artifacts/${release_name}.tar.gz" -C "${RUNNER_TEMP}" "${release_name}"
fi
- name: Publish release assets
uses: softprops/action-gh-release@v2
with:
body_path: docs/release-notes/${{ github.ref_name }}.md
files: artifacts/*
fail_on_unmatched_files: true
overwrite_files: true