build: add build-borg-using-pyinstaller.sh and use it in ci.yml

This commit is contained in:
Thomas Waldmann 2026-06-04 18:22:11 +02:00
parent 6b93751a9a
commit 2768548032
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 25 additions and 6 deletions

View file

@ -299,8 +299,7 @@ jobs:
if: ${{ matrix.binary && startsWith(github.ref, 'refs/tags/') }}
run: |
pip install -r requirements.d/pyinstaller.txt
mkdir -p dist/binary
pyinstaller --clean --distpath=dist/binary scripts/borg.exe.spec
./scripts/build-borg-using-pyinstaller.sh
- name: Smoke-test the built binary (${{ matrix.binary }})
if: ${{ matrix.binary && startsWith(github.ref, 'refs/tags/') }}
@ -471,8 +470,7 @@ jobs:
if [[ "${{ matrix.do_binaries }}" == "true" && "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
python -m pip install -r requirements.d/pyinstaller.txt
mkdir -p dist/binary
pyinstaller --clean --distpath=dist/binary scripts/borg.exe.spec
./scripts/build-borg-using-pyinstaller.sh
pushd dist/binary
echo "single-file binary"
chmod +x borg.exe
@ -665,8 +663,7 @@ jobs:
# build borg.exe
. env/bin/activate
pip install -e ".[cockpit,s3,sftp,rclone]"
mkdir -p dist/binary
pyinstaller -y --clean --distpath=dist/binary scripts/borg.exe.spec
./scripts/build-borg-using-pyinstaller.sh
# build sdist and wheel in dist/...
python -m build

View file

@ -0,0 +1,22 @@
#!/bin/bash
# Generate a single-file binary of borgbackup using PyInstaller.
set -euo pipefail
OUTPUT_DIR="dist/binary"
SPEC_FILE="scripts/borg.exe.spec"
echo "Building single-file binary of borgbackup using PyInstaller..."
# Run PyInstaller compilation
# We use -y/--noconfirm to overwrite the output directory without asking.
# We use --clean to clean PyInstaller cache and temporary files before building.
mkdir -p $OUTPUT_DIR
pyinstaller \
-y \
--clean \
--distpath="$OUTPUT_DIR" \
"$SPEC_FILE"
echo "Single-file binary generated at:"
echo "$OUTPUT_DIR/borg.exe"