-
-
Notifications
You must be signed in to change notification settings - Fork 160
278 lines (239 loc) · 8.81 KB
/
Copy pathrelease.yml
File metadata and controls
278 lines (239 loc) · 8.81 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
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: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
MOUSER_VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '' }}
MOUSER_GIT_COMMIT: ${{ github.sha }}
MOUSER_GIT_DIRTY: "false"
jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build with PyInstaller
run: pyinstaller Mouser.spec --noconfirm
- name: Create archive
run: Compress-Archive -Path dist\Mouser -DestinationPath Mouser-Windows.zip
- uses: actions/upload-artifact@v7
with:
name: Mouser-Windows
path: Mouser-Windows.zip
build-macos:
name: build-macos (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
- name: Apple Silicon
runner: macos-15
python_architecture: arm64
pyinstaller_target_arch: arm64
artifact_name: Mouser-macOS
archive_name: Mouser-macOS.zip
- name: Intel
runner: macos-15-intel
python_architecture: x64
pyinstaller_target_arch: x86_64
artifact_name: Mouser-macOS-intel
archive_name: Mouser-macOS-intel.zip
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
architecture: ${{ matrix.python_architecture }}
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build macOS app
env:
PYINSTALLER_TARGET_ARCH: ${{ matrix.pyinstaller_target_arch }}
run: |
chmod +x build_macos_app.sh
./build_macos_app.sh
- name: Create archive
run: cd dist && zip -r -y "../${{ matrix.archive_name }}" Mouser.app
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.archive_name }}
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libhidapi-dev \
libegl1 \
libxkbcommon-x11-0 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-util1 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-xkb1
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build with PyInstaller
run: pyinstaller Mouser-linux.spec --noconfirm
- name: Audit Linux bundle dependencies
run: |
python - <<'PY'
import os
import pathlib
import stat
import subprocess
bundle_root = os.path.join("dist", "Mouser")
if not os.path.isdir(bundle_root):
raise SystemExit(f"Missing bundle directory: {bundle_root}")
bundle_root_path = pathlib.Path(bundle_root).resolve()
internal_root = bundle_root_path / "_internal"
pyside_root = internal_root / "PySide6"
hidapi_root = internal_root / "hidapi.libs"
def is_elf(path: str) -> bool:
try:
mode = os.stat(path).st_mode
except OSError:
return False
if not stat.S_ISREG(mode):
return False
with open(path, "rb") as fh:
return fh.read(4) == b"\x7fELF"
library_dirs = []
for root, _, files in os.walk(bundle_root):
if any(".so" in name for name in files):
library_dirs.append(root)
ld_library_path = ":".join(dict.fromkeys(library_dirs))
env = os.environ.copy()
if ld_library_path:
env["LD_LIBRARY_PATH"] = ld_library_path
def should_audit(path: pathlib.Path) -> bool:
if path == bundle_root_path / "Mouser":
return True
try:
relative = path.relative_to(pyside_root)
return "plugins" not in relative.parts and "qml" not in relative.parts
except ValueError:
pass
try:
path.relative_to(hidapi_root)
return True
except ValueError:
return False
missing = []
for root, _, files in os.walk(bundle_root):
for name in files:
path = pathlib.Path(root, name).resolve()
if not is_elf(str(path)) or not should_audit(path):
continue
result = subprocess.run(
["ldd", str(path)],
check=False,
capture_output=True,
text=True,
env=env,
)
output = result.stdout + result.stderr
unresolved = [
line.strip()
for line in output.splitlines()
if "not found" in line
]
if unresolved:
missing.append((path, unresolved))
if missing:
for path, unresolved in missing:
print(path)
for line in unresolved:
print(f" {line}")
raise SystemExit("Linux bundle contains unresolved shared-library dependencies")
PY
- name: Smoke test Linux bundle startup
run: |
set +e
QT_QPA_PLATFORM=offscreen timeout --kill-after=5s 15s ./dist/Mouser/Mouser
status=$?
set -e
if [ "$status" -ne 0 ] && [ "$status" -ne 124 ] && [ "$status" -ne 137 ]; then
exit "$status"
fi
- name: Add Linux permission helper
run: |
cp packaging/linux/69-mouser-logitech.rules dist/Mouser/
cp packaging/linux/install-linux-permissions.sh dist/Mouser/
chmod +x dist/Mouser/install-linux-permissions.sh
- name: Create archive
run: cd dist && zip -r -y ../Mouser-Linux.zip Mouser
- uses: actions/upload-artifact@v7
with:
name: Mouser-Linux
path: Mouser-Linux.zip
release:
if: startsWith(github.ref, 'refs/tags/')
needs: [build-windows, build-macos, build-linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Generate update metadata
run: |
mkdir -p update-assets
cp Mouser-Windows/Mouser-Windows.zip update-assets/
cp Mouser-macOS/Mouser-macOS.zip update-assets/
cp Mouser-macOS-intel/Mouser-macOS-intel.zip update-assets/
cp Mouser-Linux/Mouser-Linux.zip update-assets/
python tools/generate_update_manifest.py \
--repo "${{ github.repository }}" \
--tag "${{ github.ref_name }}" \
--commit "${{ github.sha }}" \
--asset-dir update-assets \
--output "mouser-${{ github.ref_name }}-update.json"
- uses: actions/upload-artifact@v7
with:
name: Mouser-Update-Metadata
path: mouser-${{ github.ref_name }}-update.json
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "${{ github.ref_name }}" --repo "${{ github.repository }}" > /dev/null 2>&1; then
# Release already exists — just upload the assets
gh release upload "${{ github.ref_name }}" \
--repo "${{ github.repository }}" \
--clobber \
Mouser-Windows/Mouser-Windows.zip \
Mouser-macOS/Mouser-macOS.zip \
Mouser-macOS-intel/Mouser-macOS-intel.zip \
Mouser-Linux/Mouser-Linux.zip \
mouser-${{ github.ref_name }}-update.json
else
gh release create "${{ github.ref_name }}" \
--repo "${{ github.repository }}" \
--title "Mouser ${{ github.ref_name }}" \
--generate-notes \
Mouser-Windows/Mouser-Windows.zip \
Mouser-macOS/Mouser-macOS.zip \
Mouser-macOS-intel/Mouser-macOS-intel.zip \
Mouser-Linux/Mouser-Linux.zip \
mouser-${{ github.ref_name }}-update.json
fi