forked from serhmarch/ModbusTools
-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (184 loc) · 7.59 KB
/
build.yml
File metadata and controls
216 lines (184 loc) · 7.59 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
name: Build ModbusTools
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
env:
VERSION: '0.4.9'
jobs:
# ---------------------------------------------------------------------------
# Linux: Build AppImages
# ---------------------------------------------------------------------------
linux:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
cmake g++ \
qt6-base-dev qt6-tools-dev qt6-tools-dev-tools \
libqt6core5compat6-dev libqt6help6 \
libgl1-mesa-dev \
doxygen \
librsvg2-bin \
wget fuse libfuse2
- name: Configure
run: |
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build -j$(nproc)
- name: Download linuxdeploy tools
run: |
mkdir -p build/tools
wget -q -O build/tools/linuxdeploy-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget -q -O build/tools/linuxdeploy-plugin-qt-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod +x build/tools/*.AppImage
- name: Build Client AppImage
run: |
APPDIR=build/AppDir-client
rm -rf "$APPDIR"
mkdir -p "$APPDIR/usr/bin" "$APPDIR/usr/lib"
mkdir -p "$APPDIR/usr/share/applications"
mkdir -p "$APPDIR/usr/share/icons/hicolor/scalable/apps"
cp build/client "$APPDIR/usr/bin/"
cp -a build/libmodbus.so* "$APPDIR/usr/lib/"
cp -a build/libcore.so* "$APPDIR/usr/lib/"
sed 's|Exec=/opt/modbustools/client|Exec=client|' \
packaging/modbustools-client.desktop \
> "$APPDIR/usr/share/applications/modbustools-client.desktop"
cp src/client/gui/icons/client.svg \
"$APPDIR/usr/share/icons/hicolor/scalable/apps/modbustools-client.svg"
for size in 48 128 256; do
mkdir -p "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps"
rsvg-convert -w $size -h $size src/client/gui/icons/client.svg \
-o "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps/modbustools-client.png"
done
export QMAKE=$(which qmake6 2>/dev/null || which qmake)
OUTPUT="ModbusTools_Client-${{ env.VERSION }}-x86_64.AppImage" \
build/tools/linuxdeploy-x86_64.AppImage \
--appdir "$APPDIR" \
--desktop-file "$APPDIR/usr/share/applications/modbustools-client.desktop" \
--icon-file "$APPDIR/usr/share/icons/hicolor/scalable/apps/modbustools-client.svg" \
--plugin qt \
--output appimage
- name: Build Server AppImage
run: |
APPDIR=build/AppDir-server
rm -rf "$APPDIR"
mkdir -p "$APPDIR/usr/bin" "$APPDIR/usr/lib"
mkdir -p "$APPDIR/usr/share/applications"
mkdir -p "$APPDIR/usr/share/icons/hicolor/scalable/apps"
mkdir -p "$APPDIR/usr/script/server"
cp build/server "$APPDIR/usr/bin/"
cp -a build/libmodbus.so* "$APPDIR/usr/lib/"
cp -a build/libcore.so* "$APPDIR/usr/lib/"
cp -f src/server/python/*.py "$APPDIR/usr/script/server/" 2>/dev/null || true
sed 's|Exec=/opt/modbustools/server|Exec=server|' \
packaging/modbustools-server.desktop \
> "$APPDIR/usr/share/applications/modbustools-server.desktop"
cp src/server/gui/icons/server.svg \
"$APPDIR/usr/share/icons/hicolor/scalable/apps/modbustools-server.svg"
for size in 48 128 256; do
mkdir -p "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps"
rsvg-convert -w $size -h $size src/server/gui/icons/server.svg \
-o "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps/modbustools-server.png"
done
export QMAKE=$(which qmake6 2>/dev/null || which qmake)
OUTPUT="ModbusTools_Server-${{ env.VERSION }}-x86_64.AppImage" \
build/tools/linuxdeploy-x86_64.AppImage \
--appdir "$APPDIR" \
--desktop-file "$APPDIR/usr/share/applications/modbustools-server.desktop" \
--icon-file "$APPDIR/usr/share/icons/hicolor/scalable/apps/modbustools-server.svg" \
--plugin qt \
--output appimage
- name: Upload AppImages
uses: actions/upload-artifact@v4
with:
name: linux-appimages
path: |
ModbusTools_Client-*.AppImage
ModbusTools_Server-*.AppImage
# ---------------------------------------------------------------------------
# Windows: Build ZIP with Qt DLLs
# ---------------------------------------------------------------------------
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Qt6
uses: jurplel/install-qt-action@v4
with:
version: '6.7.*'
host: windows
target: desktop
arch: win64_msvc2019_64
modules: 'qt5compat'
- name: Configure
shell: cmd
run: |
cmake -B build ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_PREFIX_PATH="%Qt6_DIR%"
- name: Build
shell: cmd
run: cmake --build build --config Release
- name: Package with windeployqt
shell: cmd
run: |
mkdir dist
copy build\Release\client.exe dist\
copy build\Release\server.exe dist\
copy build\Release\modbus.dll dist\
copy build\Release\core.dll dist\
REM Copy scripts
mkdir dist\script\server
copy src\server\python\*.py dist\script\server\
REM Copy help files if they exist
if exist build\doc\output mkdir dist\help
if exist build\doc\output\*.qch copy build\doc\output\*.qch dist\help\
if exist build\doc\output\*.qhc copy build\doc\output\*.qhc dist\help\
REM Run windeployqt on both executables
windeployqt --release --no-translations dist\client.exe
windeployqt --release --no-translations dist\server.exe
- name: Create ZIP archive
shell: powershell
run: |
Compress-Archive -Path dist\* -DestinationPath "ModbusTools-${{ env.VERSION }}-windows-x64.zip"
- name: Upload Windows build
uses: actions/upload-artifact@v4
with:
name: windows-build
path: ModbusTools-${{ env.VERSION }}-windows-x64.zip
# ---------------------------------------------------------------------------
# Release: Publish artifacts on tag push
# ---------------------------------------------------------------------------
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [linux, windows]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
draft: false
generate_release_notes: true
files: |
linux-appimages/ModbusTools_Client-*.AppImage
linux-appimages/ModbusTools_Server-*.AppImage
windows-build/ModbusTools-*-windows-x64.zip