From ee0e283f13a985d2b3578b83447d20fa352af3a6 Mon Sep 17 00:00:00 2001 From: HN-Tran <53001238+HN-Tran@users.noreply.github.com> Date: Fri, 20 Mar 2026 03:11:29 +0100 Subject: [PATCH] feat: PyInstaller builds for Windows, Linux, and macOS Adds a PyInstaller hook for python-magic-standalone and a GitHub Actions workflow that builds Linux, Windows, and macOS executables on tag push or manual dispatch, with automatic GitHub Release creation. --- .github/workflows/build.yml | 65 +++++++++++++++++++++++++++++++++++++ hooks/hook-magic.py | 4 +++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 hooks/hook-magic.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..20f98e5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: Build executables + +on: + push: + tags: + - "v*" + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + include: + - os: ubuntu-latest + suffix: linux + ext: "" + - os: windows-latest + suffix: windows + ext: ".exe" + - os: macos-latest + suffix: macos + ext: "" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: pip install . pyinstaller + + - name: Build executable + run: pyinstaller --onefile --name waybackup --additional-hooks-dir=hooks pywaybackup/main.py + + - name: Rename artifact + shell: bash + run: mv "dist/waybackup${{ matrix.ext }}" "dist/waybackup-${{ matrix.suffix }}${{ matrix.ext }}" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: waybackup-${{ matrix.suffix }} + path: dist/waybackup-${{ matrix.suffix }}${{ matrix.ext }} + + release: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: artifacts/* + generate_release_notes: true diff --git a/hooks/hook-magic.py b/hooks/hook-magic.py new file mode 100644 index 0000000..d1cdf37 --- /dev/null +++ b/hooks/hook-magic.py @@ -0,0 +1,4 @@ +from PyInstaller.utils.hooks import collect_data_files, collect_dynamic_libs + +datas = collect_data_files("magic") +binaries = collect_dynamic_libs("magic")