Build Binaries #6
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: Build Binaries | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bin: | |
| description: "Binary folder/name under bins/ (e.g., faster_whisper)" | |
| required: true | |
| default: "faster_whisper" | |
| bins_dir: | |
| description: "Root folder containing binaries" | |
| required: true | |
| default: "bins" | |
| python_version: | |
| description: "Python version to use" | |
| required: true | |
| default: "3.11.9" | |
| concurrency: | |
| group: build-binaries-${{ github.ref }}-${{ inputs.bin }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| version: | |
| name: Read version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ inputs.PYTHON_VERSION }} | |
| - id: get | |
| name: Compute version | |
| shell: bash | |
| working-directory: ${{ inputs.BINS_DIR }}/${{ inputs.BIN }} | |
| run: | | |
| ver=$(python -c 'from version import __version__; print(__version__)') | |
| echo "version=$ver" >> "$GITHUB_OUTPUT" | |
| build: | |
| name: Build ${{ inputs.BIN }} (${{ matrix.arch }}) | |
| needs: version | |
| env: | |
| VERSION: ${{ needs.version.outputs.version }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| arch: linux-x86_64 | |
| python_arch: x64 | |
| - os: ubuntu-22.04-arm | |
| arch: linux-aarch64 | |
| python_arch: arm64 | |
| - os: macos-13 | |
| arch: macosx-x86_64 | |
| python_arch: x64 | |
| - os: macos-14 | |
| arch: macosx-arm64 | |
| python_arch: arm64 | |
| - os: windows-latest | |
| arch: win-amd64 | |
| python_arch: x64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - name: Set up Python ${{ matrix.python_arch }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ inputs.PYTHON_VERSION }} | |
| architecture: ${{ matrix.python_arch }} | |
| - name: Install pipenv | |
| run: python -m pip install --upgrade pip pipenv | |
| - name: Build with PyInstaller via Node script | |
| run: npm run build ${{ inputs.BIN }} | |
| - name: Collect binary (no archive) | |
| shell: bash | |
| working-directory: ${{ inputs.BINS_DIR }}/${{ inputs.BIN }} | |
| env: | |
| BIN: ${{ inputs.BIN }} | |
| ARCH: ${{ matrix.arch }} | |
| run: | | |
| EXT="" | |
| [ "${{ runner.os }}" = "Windows" ] && EXT=".exe" || true | |
| SRC="dist/$BIN$EXT"; [ -f "$SRC" ] || SRC="dist/$BIN/$BIN$EXT" | |
| [ -f "$SRC" ] || { echo "Binary not found in dist/"; ls -R dist || true; exit 1; } | |
| mkdir -p "$GITHUB_WORKSPACE/out" | |
| cp -f "$SRC" "$GITHUB_WORKSPACE/out/${BIN}_${VERSION}-${ARCH}$EXT" | |
| chmod +x "$GITHUB_WORKSPACE/out/${BIN}_${VERSION}-${ARCH}$EXT" || true | |
| ls -la "$GITHUB_WORKSPACE/out" | |
| - name: Upload artifact (raw binary) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ inputs.BIN }}_${{ env.VERSION }}-${{ matrix.arch }} | |
| path: out/* | |
| compression-level: 0 | |
| release: | |
| name: Release ${{ inputs.BIN }} v${{ needs.version.outputs.version }} | |
| needs: [build, version] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release_assets | |
| merge-multiple: true | |
| - name: List assets | |
| run: ls -la release_assets | |
| - name: Create or update GitHub Release (raw assets) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.BIN }}-v${{ needs.version.outputs.version }} | |
| name: ${{ inputs.BIN }} v${{ needs.version.outputs.version }} | |
| body: | | |
| Automated release for ${{ inputs.BIN }} version ${{ needs.version.outputs.version }}. | |
| Includes raw binaries for multiple architectures. | |
| files: release_assets/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |