From 18f29722c93674b515c8d458b42bd6b390dab3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E5=B0=8F=E5=87=A1?= <2672931+whyb@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:16:46 +0800 Subject: [PATCH 1/5] Add github ci(Build with PyInstaller) --- .github/workflows/pyinstaller-release.yml | 126 ++++++++++++++++++ .../{python-publish.yml => pypi-publish.yml} | 0 2 files changed, 126 insertions(+) create mode 100644 .github/workflows/pyinstaller-release.yml rename .github/workflows/{python-publish.yml => pypi-publish.yml} (100%) diff --git a/.github/workflows/pyinstaller-release.yml b/.github/workflows/pyinstaller-release.yml new file mode 100644 index 0000000..f92379b --- /dev/null +++ b/.github/workflows/pyinstaller-release.yml @@ -0,0 +1,126 @@ +name: Build and Release Binaries + +on: + push: + branches: [ "main", "testci" ] + workflow_dispatch: + +permissions: + contents: write + +env: + ENTRY_POINT: "src/HwCodecDetect/run_tests.py" + APP_NAME: "HwCodecDetect" + +jobs: + build: + name: Build on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + artifact_name: HwCodecDetect-Windows.exe + asset_name: HwCodecDetect-Windows.exe + target_arch: x64 + + - os: ubuntu-20.04 + artifact_name: HwCodecDetect-Linux + asset_name: HwCodecDetect-Linux + target_arch: x64 + + - os: macos-latest + artifact_name: HwCodecDetect-macOS + asset_name: HwCodecDetect-macOS + target_arch: x64 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install build wheel setuptools pyinstaller + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install . + + - name: Build with PyInstaller (Windows) + if: runner.os == 'Windows' + run: | + pyinstaller --clean --onefile --name ${{ env.APP_NAME }} ` + --distpath dist ` + --workpath build ` + "${{ env.ENTRY_POINT }}" + Move-Item -Path "dist\${{ env.APP_NAME }}.exe" -Destination "dist\${{ matrix.artifact_name }}" + + - name: Build with PyInstaller (Linux/macOS) + if: runner.os != 'Windows' + run: | + pyinstaller --clean --onefile --name ${{ env.APP_NAME }} \ + --distpath dist \ + --workpath build \ + "${{ env.ENTRY_POINT }}" + mv "dist/${{ env.APP_NAME }}" "dist/${{ matrix.artifact_name }}" + + - name: Test Binary Execution (Smoke Test) + shell: bash + run: | + # test run command --help + if [ "$RUNNER_OS" == "Windows" ]; then + ./dist/${{ matrix.artifact_name }} --help || echo "Binary ran with exit code $?" + else + chmod +x ./dist/${{ matrix.artifact_name }} + ./dist/${{ matrix.artifact_name }} --help || echo "Binary ran with exit code $?" + fi + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.asset_name }} + path: dist/${{ matrix.artifact_name }} + if-no-files-found: error + + create-release: + name: Create Draft Release + needs: build + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Display structure of downloaded files + run: ls -R artifacts + + - name: Get Current Date and SHA + id: vars + run: | + echo "date=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT + echo "short_sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT + + - name: Create Release (Draft) + uses: softprops/action-gh-release@v1 + with: + tag_name: build-${{ github.ref_name }}-${{ steps.vars.outputs.date }}-${{ steps.vars.outputs.short_sha }} + name: "Build: ${{ github.ref_name }} (${{ steps.vars.outputs.date }})" + body: | + Automated build from branch: **${{ github.ref_name }}** + Commit: ${{ github.sha }} + + ### How to use: + Download the binary for your platform. + *Note: You likely need FFmpeg installed on your system path.* + draft: true + prerelease: true + files: | + artifacts/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/python-publish.yml b/.github/workflows/pypi-publish.yml similarity index 100% rename from .github/workflows/python-publish.yml rename to .github/workflows/pypi-publish.yml From cc6faa88c3ecc157b238a1752a0d934b64933630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E5=B0=8F=E5=87=A1?= <2672931+whyb@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:38:20 +0800 Subject: [PATCH 2/5] Fix ci error --- .github/workflows/pyinstaller-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pyinstaller-release.yml b/.github/workflows/pyinstaller-release.yml index f92379b..c993f58 100644 --- a/.github/workflows/pyinstaller-release.yml +++ b/.github/workflows/pyinstaller-release.yml @@ -1,4 +1,4 @@ -name: Build and Release Binaries +name: PyInstaller Build and Release Binaries on: push: @@ -44,6 +44,7 @@ jobs: python-version: "3.10" - name: Install Dependencies + shell: bash run: | python -m pip install --upgrade pip pip install build wheel setuptools pyinstaller From 040aee134a41f579ca69f0ee60de4cb3ced7e1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E5=B0=8F=E5=87=A1?= <2672931+whyb@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:47:54 +0800 Subject: [PATCH 3/5] CI Create Entry Point Script(launcher.py) --- .github/workflows/pyinstaller-release.yml | 32 ++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pyinstaller-release.yml b/.github/workflows/pyinstaller-release.yml index c993f58..f47f845 100644 --- a/.github/workflows/pyinstaller-release.yml +++ b/.github/workflows/pyinstaller-release.yml @@ -9,7 +9,7 @@ permissions: contents: write env: - ENTRY_POINT: "src/HwCodecDetect/run_tests.py" + ENTRY_POINT: "launcher.py" APP_NAME: "HwCodecDetect" jobs: @@ -51,10 +51,29 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install . + - name: Create Entry Point Script + shell: bash + run: | + cat > launcher.py < Date: Wed, 19 Nov 2025 16:06:45 +0800 Subject: [PATCH 4/5] Add multi-platform build --- .github/workflows/pyinstaller-release.yml | 184 +++++++++++++++------- 1 file changed, 125 insertions(+), 59 deletions(-) diff --git a/.github/workflows/pyinstaller-release.yml b/.github/workflows/pyinstaller-release.yml index f47f845..51b9716 100644 --- a/.github/workflows/pyinstaller-release.yml +++ b/.github/workflows/pyinstaller-release.yml @@ -9,97 +9,160 @@ permissions: contents: write env: - ENTRY_POINT: "launcher.py" APP_NAME: "HwCodecDetect" + ENTRY_POINT_SCRIPT: "launcher.py" jobs: build: - name: Build on ${{ matrix.os }} + name: Build ${{ matrix.asset_name }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: + # --- Windows --- - os: windows-latest - artifact_name: HwCodecDetect-Windows.exe - asset_name: HwCodecDetect-Windows.exe - target_arch: x64 + python_arch: 'x64' + artifact_name: HwCodecDetect-Windows-x64.exe + asset_name: HwCodecDetect-Windows-x64.exe + job_type: native - - os: ubuntu-20.04 - artifact_name: HwCodecDetect-Linux - asset_name: HwCodecDetect-Linux - target_arch: x64 - - - os: macos-latest - artifact_name: HwCodecDetect-macOS - asset_name: HwCodecDetect-macOS - target_arch: x64 + - os: windows-latest + python_arch: 'x86' # 32bit Windows + artifact_name: HwCodecDetect-Windows-x86.exe + asset_name: HwCodecDetect-Windows-x86.exe + job_type: native + + # --- macOS --- + - os: macos-13 # Intel Macs (runs on x86_64) + python_arch: 'x64' + artifact_name: HwCodecDetect-macOS-Intel + asset_name: HwCodecDetect-macOS-Intel + job_type: native + + - os: macos-latest # Apple Silicon (runs on arm64/M1/M2) + python_arch: 'arm64' + artifact_name: HwCodecDetect-macOS-ARM64 + asset_name: HwCodecDetect-macOS-ARM64 + job_type: native + + # --- Linux Native (x64) --- + - os: ubuntu-22.04 + python_arch: 'x64' + artifact_name: HwCodecDetect-Linux-x64 + asset_name: HwCodecDetect-Linux-x64 + job_type: native + + # --- Linux Emulated (ARM64 / aarch64) --- + - os: ubuntu-22.04 + job_type: emulated + qemu_arch: aarch64 + docker_img: python:3.10-bullseye + artifact_name: HwCodecDetect-Linux-arm64 + asset_name: HwCodecDetect-Linux-arm64 + + # --- Linux Emulated (x86 / i386) --- + - os: ubuntu-22.04 + job_type: emulated + qemu_arch: i386 + docker_img: i386/python:3.10-slim-bullseye + artifact_name: HwCodecDetect-Linux-x86 + asset_name: HwCodecDetect-Linux-x86 steps: - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install Dependencies - shell: bash - run: | - python -m pip install --upgrade pip - pip install build wheel setuptools pyinstaller - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - pip install . - - name: Create Entry Point Script shell: bash run: | - cat > launcher.py < ${{ env.ENTRY_POINT_SCRIPT }} <> $GITHUB_OUTPUT @@ -133,12 +196,15 @@ jobs: tag_name: build-${{ github.ref_name }}-${{ steps.vars.outputs.date }}-${{ steps.vars.outputs.short_sha }} name: "Build: ${{ github.ref_name }} (${{ steps.vars.outputs.date }})" body: | - Automated build from branch: **${{ github.ref_name }}** + Automated multi-platform build. Commit: ${{ github.sha }} - ### How to use: - Download the binary for your platform. - *Note: You likely need FFmpeg installed on your system path.* + ### Supported Platforms: + - **Windows**: x64, x86 (32-bit) + - **macOS**: Apple Silicon (ARM64), Intel + - **Linux**: x64, ARM64, x86 + + *Note: Windows ARM users should use the Windows x86 or x64 binary.* draft: true prerelease: true files: | From 2290df2222e877452baa70245e8dba4ef297289d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E5=B0=8F=E5=87=A1?= <2672931+whyb@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:41:14 +0800 Subject: [PATCH 5/5] tags "v*.*.*" --- .github/workflows/pyinstaller-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pyinstaller-release.yml b/.github/workflows/pyinstaller-release.yml index 51b9716..6e90001 100644 --- a/.github/workflows/pyinstaller-release.yml +++ b/.github/workflows/pyinstaller-release.yml @@ -2,11 +2,14 @@ name: PyInstaller Build and Release Binaries on: push: + tags: + - "v*.*.*" branches: [ "main", "testci" ] workflow_dispatch: permissions: contents: write + discussions: write env: APP_NAME: "HwCodecDetect"