-
-
Notifications
You must be signed in to change notification settings - Fork 76
463 lines (414 loc) · 15.9 KB
/
develop.yml
File metadata and controls
463 lines (414 loc) · 15.9 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
name: Docker Develop Release
on:
push:
branches: [develop]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-binaries:
name: Build Standalone Binaries (${{ matrix.os }})
permissions:
contents: read
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.12"
- os: windows-latest
python-version: "3.12"
- os: "macos-latest" # for Arm based macs (M1 and above).
python-version: "3.12"
arch: arm64
- os: "macos-15-intel" # for Intel based macs.
python-version: "3.12"
arch: x86_64
env:
APP_NAME: qbit-manage
ENTRY: qbit_manage.py
steps:
- name: Check Out Repo
uses: actions/checkout@v6
with:
ref: develop
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
pyproject.toml
uv.lock
- name: Upgrade Pip and install project + PyInstaller
run: |
python -m pip install --upgrade pip wheel
python -m pip install . pyinstaller
- name: Compute add-data separator
id: sep
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
echo "SEP=;" >> $GITHUB_OUTPUT
else
echo "SEP=:" >> $GITHUB_OUTPUT
fi
- name: Build (PyInstaller onefile)
shell: bash
run: |
ADD_WEBUI="web-ui${{ steps.sep.outputs.SEP }}web-ui"
ADD_SAMPLE_CFG="config/config.yml.sample${{ steps.sep.outputs.SEP }}config"
ADD_LOGO="icons/qbm_logo.png${{ steps.sep.outputs.SEP }}."
ADD_VERSION="VERSION${{ steps.sep.outputs.SEP }}."
ADD_DOCS="docs${{ steps.sep.outputs.SEP }}docs"
ICON_ARG=""
if [[ "${{ runner.os }}" == "Windows" ]]; then
ICON_ARG=--icon=icons/qbm_logo.ico
elif [[ "${{ runner.os }}" == "macOS" ]]; then
ICON_ARG=--icon=icons/qbm_logo.icns
else
# Linux: optional icon (helps some desktop environments)
if [[ -f icons/qbm_logo.png ]]; then
ICON_ARG=--icon=icons/qbm_logo.png
elif [[ -f icons/qbm_logo.ico ]]; then
ICON_ARG=--icon=icons/qbm_logo.ico
fi
fi
pyinstaller --noconfirm \
--clean \
--onefile \
--name "${APP_NAME}" \
--add-data "$ADD_WEBUI" \
--add-data "$ADD_SAMPLE_CFG" \
--add-data "$ADD_LOGO" \
--add-data "$ADD_VERSION" \
--add-data "$ADD_DOCS" \
$ICON_ARG \
"${ENTRY}"
- name: Rename output for OS
shell: bash
run: |
mkdir -p out
if [[ "${{ runner.os }}" == "Windows" ]]; then
mv "dist/${APP_NAME}.exe" "out/${APP_NAME}-windows-amd64.exe"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
ARCH=$(uname -m)
if [[ "$ARCH" == "arm64" ]]; then
mv "dist/${APP_NAME}" "out/${APP_NAME}-macos-arm64"
else
mv "dist/${APP_NAME}" "out/${APP_NAME}-macos-x86_64"
fi
else
mv "dist/${APP_NAME}" "out/${APP_NAME}-linux-amd64"
fi
# Build Tauri desktop shell after binaries are ready
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
env:
RUSTUP_MAX_RETRIES: 10
timeout-minutes: 10
continue-on-error: true
id: rust-setup
- name: Wait before retry (network recovery)
if: steps.rust-setup.outcome == 'failure'
run: sleep 30
shell: bash
- name: Retry Rust toolchain setup on failure
if: steps.rust-setup.outcome == 'failure'
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
env:
RUSTUP_MAX_RETRIES: 10
timeout-minutes: 10
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: |
desktop/tauri/src-tauri -> desktop/tauri/src-tauri/target
- name: Install NSIS (Windows)
if: runner.os == 'Windows'
shell: powershell
run: choco install nsis -y
- name: Install Tauri dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
# Ubuntu 24.04 (noble) uses libwebkit2gtk-4.1-dev (4.0 no longer available)
# Install core deps first
sudo apt-get install -y libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
# Try new package name, fall back for older runners
sudo apt-get install -y libwebkit2gtk-4.1-dev || sudo apt-get install -y libwebkit2gtk-4.0-dev
- name: Prepare Tauri server binary
shell: bash
run: |
mkdir -p desktop/tauri/src-tauri/bin
# Copy the actual binary for this platform as a resource
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp "out/${APP_NAME}-windows-amd64.exe" "desktop/tauri/src-tauri/bin/qbit-manage-windows-amd64.exe"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
ARCH=$(uname -m)
if [[ "$ARCH" == "arm64" ]]; then
cp "out/${APP_NAME}-macos-arm64" "desktop/tauri/src-tauri/bin/qbit-manage-macos-arm64"
chmod +x "desktop/tauri/src-tauri/bin/qbit-manage-macos-arm64"
else
cp "out/${APP_NAME}-macos-x86_64" "desktop/tauri/src-tauri/bin/qbit-manage-macos-x86_64"
chmod +x "desktop/tauri/src-tauri/bin/qbit-manage-macos-x86_64"
fi
else
cp "out/${APP_NAME}-linux-amd64" "desktop/tauri/src-tauri/bin/qbit-manage-linux-amd64"
chmod +x "desktop/tauri/src-tauri/bin/qbit-manage-linux-amd64"
fi
- name: Update Tauri version files
working-directory: desktop/tauri/src-tauri
shell: bash
run: |
# Run cargo check to trigger build script and update version files
cargo check
- name: Install Tauri CLI
working-directory: desktop/tauri/src-tauri
shell: bash
run: |
# Install Tauri 2 CLI (project migrated to Tauri v2 config & deps)
cargo install tauri-cli --version ^2 --locked --force
- name: Build Tauri app (initial attempt)
working-directory: desktop/tauri/src-tauri
shell: bash
run: |
# Build with explicit bundle targets for this platform
if [[ "${{ runner.os }}" == "Windows" ]]; then
cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis
elif [[ "${{ runner.os }}" == "macOS" ]]; then
cargo tauri build --bundles app,dmg
else
cargo tauri build --bundles deb
fi
continue-on-error: true
id: tauri-build
- name: Wait before retry (macOS DMG recovery)
if: steps.tauri-build.outcome == 'failure' && runner.os == 'macOS'
run: sleep 30
shell: bash
- name: Wait before retry (build recovery)
if: steps.tauri-build.outcome == 'failure'
run: sleep 30
shell: bash
- name: Retry Tauri build on failure (attempt 2)
if: steps.tauri-build.outcome == 'failure'
working-directory: desktop/tauri/src-tauri
shell: bash
run: |
# Build with explicit bundle targets for this platform
if [[ "${{ runner.os }}" == "Windows" ]]; then
cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis
elif [[ "${{ runner.os }}" == "macOS" ]]; then
cargo tauri build --bundles app,dmg
else
cargo tauri build --bundles deb
fi
continue-on-error: true
id: tauri-build-retry1
- name: Wait before final retry (build recovery)
if: steps.tauri-build-retry1.outcome == 'failure'
run: sleep 30
shell: bash
- name: Final retry Tauri build on failure (attempt 3)
if: steps.tauri-build-retry1.outcome == 'failure'
working-directory: desktop/tauri/src-tauri
shell: bash
run: |
# Build with explicit bundle targets for this platform
if [[ "${{ runner.os }}" == "Windows" ]]; then
cargo tauri build --target x86_64-pc-windows-msvc --bundles nsis
elif [[ "${{ runner.os }}" == "macOS" ]]; then
cargo tauri build --bundles app,dmg
else
cargo tauri build --bundles deb
fi
- name: Fail if all Tauri build attempts failed
if: steps.tauri-build.outcome == 'failure' && steps.tauri-build-retry1.outcome == 'failure'
shell: bash
run: |
echo "❌ Tauri build failed after all attempts"
exit 1
- name: Set BUILD_ARCH for artifact naming
shell: bash
run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then
ARCH=$(uname -m)
if [[ "$ARCH" == "arm64" ]]; then
echo "BUILD_ARCH=arm64" >> $GITHUB_ENV
else
echo "BUILD_ARCH=x86_64" >> $GITHUB_ENV
fi
elif [[ "${{ runner.os }}" == "Windows" ]]; then
echo "BUILD_ARCH=amd64" >> $GITHUB_ENV
else
echo "BUILD_ARCH=amd64" >> $GITHUB_ENV
fi
- name: Upload build outputs (binary + Tauri bundles)
uses: actions/upload-artifact@v6
with:
name: build-outputs-${{ runner.os }}-${{ env.BUILD_ARCH }}
path: |
out/**
desktop/tauri/src-tauri/target/**/release/bundle/**
if-no-files-found: error
retention-days: 7
compression-level: 0
prepare-release-assets:
runs-on: ubuntu-latest
needs: build-binaries
permissions:
actions: write
contents: read
steps:
- name: Download and collect all build outputs
uses: actions/download-artifact@v8
with:
pattern: build-outputs-*
path: collected
merge-multiple: true
- name: Filter and rename files for release
shell: bash
run: |
set -euo pipefail
mkdir -p release-assets
echo "=== Collecting server binaries (standalone executables) ==="
# Copy server binaries with error checking
server_files=(
"qbit-manage-linux-amd64"
"qbit-manage-macos-arm64"
"qbit-manage-macos-x86_64"
"qbit-manage-windows-amd64.exe"
)
for server_file in "${server_files[@]}"; do
if find collected -name "$server_file" -exec cp {} release-assets/ \; -print | grep -q .; then
echo "✓ Found and copied: $server_file"
else
echo "⚠️ Warning: $server_file not found"
fi
done
echo "=== Processing installer files (desktop app packages) ==="
# Linux .deb installer
deb_count=$(find collected -name "*.deb" -exec cp {} release-assets/ \; -print | wc -l)
if [ "$deb_count" -gt 0 ]; then
echo "✓ Found $deb_count .deb installer(s)"
for file in release-assets/*.deb; do
if [ -f "$file" ]; then
basename=$(basename "$file" .deb)
mv "$file" "release-assets/${basename}-desktop-installer.deb"
echo " → Renamed to: ${basename}-desktop-installer.deb"
fi
done
else
echo "⚠️ Warning: No .deb installers found"
fi
# macOS .dmg installers
dmg_count=$(find collected -name "*.dmg" -exec cp {} release-assets/ \; -print | wc -l)
if [ "$dmg_count" -gt 0 ]; then
echo "✓ Found $dmg_count .dmg installer(s)"
for file in release-assets/*.dmg; do
if [ -f "$file" ]; then
basename=$(basename "$file" .dmg)
mv "$file" "release-assets/${basename}-desktop-installer.dmg"
echo " → Renamed to: ${basename}-desktop-installer.dmg"
fi
done
else
echo "⚠️ Warning: No .dmg installers found"
fi
# Windows .exe installer
exe_count=$(find collected -name "*-setup.exe" -exec cp {} release-assets/ \; -print | wc -l)
if [ "$exe_count" -gt 0 ]; then
echo "✓ Found $exe_count .exe installer(s)"
for file in release-assets/*-setup.exe; do
if [ -f "$file" ]; then
basename=$(basename "$file" -setup.exe)
mv "$file" "release-assets/${basename}-desktop-installer-setup.exe"
echo " → Renamed to: ${basename}-desktop-installer-setup.exe"
fi
done
else
echo "⚠️ Warning: No .exe installers found"
fi
echo "=== File processing completed ==="
- name: Display final release assets
run: |
echo "=== Final Release Assets ==="
ls -la release-assets/
echo ""
echo "=== File Count Summary ==="
echo "Server binaries: $(find release-assets -name "qbit-manage-*" -not -name "*desktop*" | wc -l)"
echo "Desktop installers: $(find release-assets -name "*desktop-installer*" | wc -l)"
- name: Upload final release assets
uses: actions/upload-artifact@v6
with:
name: qbit-manage-release-assets
path: release-assets/*
if-no-files-found: error
compression-level: 6
docker-develop:
runs-on: ubuntu-latest
steps:
- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: "${{ github.repository_owner }}"
- name: Check Out Repo
uses: actions/checkout@v6
with:
ref: develop
- name: Trigger Hotio Webhook
uses: joelwmale/webhook-action@master
with:
url: ${{ secrets.HOTIO_WEBHOOK_URL }}
headers: '{"Authorization": "Bearer ${{ secrets.HOTIO_WEBHOOK_SECRET }}"}'
body: '{ "application": "qbitmanage", "branch": "nightly" }'
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ env.OWNER_LC }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Read version from VERSION file
id: get_version
run: echo "APP_VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: Set build metadata
id: build_meta
run: |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "VCS_REF=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./
file: ./Dockerfile
build-args: |
BRANCH_NAME=develop
APP_VERSION=${{ steps.get_version.outputs.APP_VERSION }}
BUILD_DATE=${{ steps.build_meta.outputs.BUILD_DATE }}
VCS_REF=${{ steps.build_meta.outputs.VCS_REF }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/qbit_manage:develop
ghcr.io/${{ env.OWNER_LC }}/qbit_manage:develop