name: Create Executables on: workflow_dispatch: release: types: [published] permissions: contents: write jobs: build: name: Build executables (${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: windows-latest artifact_suffix: windows - os: ubuntu-latest artifact_suffix: linux - os: macos-latest artifact_suffix: macos steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install Linux system dependencies if: runner.os == 'Linux' run: sudo apt-get update && sudo apt-get install -y libxcb-cursor0 libxcb-xinerama0 - name: Install Python dependencies run: | python -m pip install --upgrade pip wheel setuptools python -m pip install -r requirements.txt python -m pip install pyinstaller pyinstaller_versionfile - name: Build client run: pyinstaller --clean client.spec - name: Build server run: pyinstaller --clean server.spec - name: Package build outputs shell: bash env: ARTIFACT_SUFFIX: ${{ matrix.artifact_suffix }} run: | python - <<'PY' from pathlib import Path import os import zipfile suffix = os.environ['ARTIFACT_SUFFIX'] dist_dir = Path('dist') asset_dir = Path('release-assets') asset_dir.mkdir(exist_ok=True) for app_name in ('Zordon-client', 'Zordon-server'): source = next( ( path for path in ( dist_dir / f'{app_name}.exe', dist_dir / f'{app_name}.app', dist_dir / app_name, ) if path.exists() ), None, ) if source is None: raise FileNotFoundError(f'Could not find PyInstaller output for {app_name}') zip_path = asset_dir / f'{app_name}-{suffix}.zip' with zipfile.ZipFile(zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zip_file: if source.is_dir(): for file_path in source.rglob('*'): if file_path.is_file(): zip_file.write(file_path, source.name / file_path.relative_to(source)) else: zip_file.write(source, source.name) PY - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: Zordon-build-${{ matrix.artifact_suffix }} path: release-assets/*.zip if-no-files-found: error - name: Attach assets to release if: github.event_name == 'release' shell: bash env: GH_TOKEN: ${{ github.token }} run: gh release upload "${{ github.event.release.tag_name }}" release-assets/*.zip --clobber