add pyinstaller ci for ui #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PyInstaller Build and Release Binaries | |
| on: | |
| push: | |
| tags: [ "v*.*.*" ] | |
| branches: [ "main", "testci", "ui" ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| discussions: write | |
| env: | |
| BASE_APP_NAME: "HwCodecDetect" | |
| ENTRY_POINT_SCRIPT: "launcher.py" | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.asset_name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # ======================== MAIN BRANCH (CLI) ======================== | |
| - os: windows-latest | |
| python_arch: 'x64' | |
| asset_name: HwCodecDetect-Windows-x64.exe | |
| job_type: native | |
| branch_mode: main | |
| - os: windows-latest | |
| python_arch: 'x86' | |
| asset_name: HwCodecDetect-Windows-x86.exe | |
| job_type: native | |
| branch_mode: main | |
| - os: macos-15-intel | |
| python_arch: 'x64' | |
| asset_name: HwCodecDetect-macOS-Intel | |
| job_type: native | |
| branch_mode: main | |
| - os: macos-latest | |
| python_arch: 'arm64' | |
| asset_name: HwCodecDetect-macOS-ARM64 | |
| job_type: native | |
| branch_mode: main | |
| - os: ubuntu-22.04 | |
| python_arch: 'x64' | |
| asset_name: HwCodecDetect-Linux-x64 | |
| job_type: native | |
| branch_mode: main | |
| - os: ubuntu-22.04 | |
| job_type: emulated | |
| qemu_arch: aarch64 | |
| docker_img: python:3.10-bullseye | |
| asset_name: HwCodecDetect-Linux-arm64 | |
| branch_mode: main | |
| - os: ubuntu-22.04 | |
| job_type: emulated | |
| qemu_arch: i386 | |
| docker_img: i386/python:3.10-slim-bullseye | |
| asset_name: HwCodecDetect-Linux-x86 | |
| branch_mode: main | |
| # ======================== UI BRANCH (GUI) ======================== | |
| - os: windows-latest | |
| python_arch: 'x64' | |
| asset_name: HwCodecDetect-GUI-Windows-x64.exe | |
| job_type: native | |
| branch_mode: ui | |
| - os: windows-latest | |
| python_arch: 'x86' | |
| asset_name: HwCodecDetect-GUI-Windows-x86.exe | |
| job_type: native | |
| branch_mode: ui | |
| - os: macos-15-intel | |
| python_arch: 'x64' | |
| asset_name: HwCodecDetect-GUI-macOS-Intel | |
| job_type: native | |
| branch_mode: ui | |
| - os: macos-latest | |
| python_arch: 'arm64' | |
| asset_name: HwCodecDetect-GUI-macOS-ARM64 | |
| job_type: native | |
| branch_mode: ui | |
| - os: ubuntu-22.04 | |
| python_arch: 'x64' | |
| asset_name: HwCodecDetect-GUI-Linux-x64 | |
| job_type: native | |
| branch_mode: ui | |
| - os: ubuntu-22.04 | |
| job_type: emulated | |
| qemu_arch: aarch64 | |
| docker_img: python:3.10-bullseye | |
| asset_name: HwCodecDetect-GUI-Linux-arm64 | |
| branch_mode: ui | |
| - os: ubuntu-22.04 | |
| job_type: emulated | |
| qemu_arch: i386 | |
| docker_img: i386/python:3.10-slim-bullseye | |
| asset_name: HwCodecDetect-GUI-Linux-x86 | |
| branch_mode: ui | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ matrix.branch_mode }} | |
| - name: Set App Name | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.branch_mode }}" == "ui" ]; then | |
| echo "APP_NAME_INTERNAL=${{ env.BASE_APP_NAME }}-GUI" >> $GITHUB_ENV | |
| else | |
| echo "APP_NAME_INTERNAL=${{ env.BASE_APP_NAME }}" >> $GITHUB_ENV | |
| fi | |
| - name: Create Entry Point Script | |
| shell: bash | |
| run: | | |
| cat > ${{ env.ENTRY_POINT_SCRIPT }} <<EOF | |
| import runpy | |
| import sys | |
| import os | |
| sys.path.append(os.path.abspath(".")) | |
| if False: | |
| import src.HwCodecDetect.run_tests | |
| if __name__ == "__main__": | |
| runpy.run_module('src.HwCodecDetect.run_tests', run_name='__main__', alter_sys=True) | |
| EOF | |
| - name: Set up Python (Native) | |
| if: matrix.job_type == 'native' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| architecture: ${{ matrix.python_arch }} | |
| - name: Install & Build (Native) | |
| if: matrix.job_type == 'native' | |
| 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 . | |
| if [ "$RUNNER_OS" == "Windows" ]; then SEP=";"; else SEP=":"; fi | |
| pyinstaller --clean --onefile --name ${{ env.APP_NAME_INTERNAL }} \ | |
| --add-data "VERSION${SEP}." \ | |
| --paths ".$SEP" \ | |
| --distpath dist \ | |
| --workpath build \ | |
| "${{ env.ENTRY_POINT_SCRIPT }}" | |
| - name: Build on Linux ${{ matrix.qemu_arch }} (Emulated) | |
| if: matrix.job_type == 'emulated' | |
| uses: uraimo/run-on-arch-action@v2 | |
| with: | |
| arch: ${{ matrix.qemu_arch }} | |
| distro: bullseye | |
| githubToken: ${{ github.token }} | |
| dockerRunArgs: | | |
| --volume "${{ github.workspace }}:/work" | |
| base_image: ${{ matrix.docker_img }} | |
| run: | | |
| cd /work | |
| apt-get update && apt-get install -y --no-install-recommends build-essential gcc zlib1g-dev git | |
| python3 -m pip install --upgrade pip | |
| pip install build wheel setuptools pyinstaller | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| pip install . | |
| pyinstaller --clean --onefile --name ${{ env.APP_NAME_INTERNAL }} \ | |
| --add-data "VERSION:." \ | |
| --paths . \ | |
| --distpath dist \ | |
| --workpath build \ | |
| "${{ env.ENTRY_POINT_SCRIPT }}" | |
| chmod -R 777 dist/ | |
| - name: Rename Artifacts (Standardize) | |
| shell: bash | |
| run: | | |
| cd dist || exit 1 | |
| if [ -f "${{ env.APP_NAME_INTERNAL }}.exe" ]; then | |
| mv "${{ env.APP_NAME_INTERNAL }}.exe" "${{ matrix.asset_name }}" | |
| elif [ -f "${{ env.APP_NAME_INTERNAL }}" ]; then | |
| mv "${{ env.APP_NAME_INTERNAL }}" "${{ matrix.asset_name }}" | |
| fi | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: dist/${{ matrix.asset_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: Create Release (Draft) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: "${{ github.ref_name }}" | |
| body: | | |
| Automated multi-platform build for CLI and GUI. | |
| - **CLI Version**: main branch | |
| - **GUI Version**: ui branch | |
| draft: true | |
| prerelease: true | |
| files: | | |
| artifacts/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |