Introduce fastly-compute-py build tool #1
Workflow file for this run
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 Wheels | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| build-wheels: | |
| name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| platform: linux | |
| # Linux aarch64 | |
| - os: ubuntu-latest | |
| arch: aarch64 | |
| platform: linux | |
| # macOS x86_64 (Intel) | |
| - os: macos-13 | |
| arch: x86_64 | |
| platform: macos | |
| # macOS aarch64 (Apple Silicon) | |
| - os: macos-14 | |
| arch: aarch64 | |
| platform: macos | |
| # Windows x86_64 | |
| - os: windows-latest | |
| arch: x86_64 | |
| platform: windows | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Get wasiless submodule (if not already checked out) | |
| if: matrix.platform != 'windows' | |
| env: | |
| SSHK: ${{ secrets.WASILESS_REPO_READ_KEY }} | |
| run: | | |
| if [ ! -f crates/wasiless/Cargo.toml ]; then | |
| mkdir -p $HOME/.ssh | |
| echo "$SSHK" > $HOME/.ssh/ssh.key | |
| chmod 600 $HOME/.ssh/ssh.key | |
| export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/ssh.key" | |
| git submodule update --init --recursive | |
| fi | |
| - name: Get wasiless submodule (Windows) | |
| if: matrix.platform == 'windows' | |
| env: | |
| SSHK: ${{ secrets.WASILESS_REPO_READ_KEY }} | |
| shell: pwsh | |
| run: | | |
| if (!(Test-Path "crates/wasiless/Cargo.toml")) { | |
| New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.ssh" | |
| Set-Content -Path "$env:USERPROFILE\.ssh\ssh.key" -Value $env:SSHK | |
| $env:GIT_SSH_COMMAND = "ssh -i $env:USERPROFILE\.ssh\ssh.key" | |
| git submodule update --init --recursive | |
| } | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: wasm32-unknown-unknown | |
| - name: Install wasm-tools (Unix) | |
| if: matrix.platform != 'windows' | |
| run: cargo install wasm-tools | |
| - name: Install wasm-tools (Windows) | |
| if: matrix.platform == 'windows' | |
| run: cargo install wasm-tools | |
| - name: Set up QEMU (for Linux aarch64) | |
| if: matrix.platform == 'linux' && matrix.arch == 'aarch64' | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.arch }} | |
| args: --release --out dist --find-interpreter | |
| sccache: 'true' | |
| manylinux: auto | |
| before-script-linux: | | |
| # Install wasm-tools in the manylinux container | |
| curl -L https://github.com/bytecodealliance/wasm-tools/releases/download/v1.220.0/wasm-tools-1.220.0-${{ matrix.arch }}-linux.tar.gz | tar xzf - -C /usr/local/bin --strip-components=1 | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.platform }}-${{ matrix.arch }} | |
| path: dist/*.whl | |
| if-no-files-found: error | |
| # Build source distribution | |
| build-sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Get wasiless submodule | |
| env: | |
| SSHK: ${{ secrets.WASILESS_REPO_READ_KEY }} | |
| run: | | |
| if [ ! -f crates/wasiless/Cargo.toml ]; then | |
| mkdir -p $HOME/.ssh | |
| echo "$SSHK" > $HOME/.ssh/ssh.key | |
| chmod 600 $HOME/.ssh/ssh.key | |
| export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/ssh.key" | |
| git submodule update --init --recursive | |
| fi | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: wasm32-unknown-unknown | |
| - name: Install wasm-tools | |
| run: cargo install wasm-tools | |
| - name: Build sdist | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| if-no-files-found: error | |
| # Test installing wheels on different platforms | |
| test-wheels: | |
| name: Test wheel on ${{ matrix.os }} | |
| needs: [build-wheels] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-13, macos-14, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Download wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Install wheel (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| pip install --find-links dist fastly-compute | |
| python -c "import fastly_compute; print('Successfully imported fastly_compute')" | |
| - name: Install wheel (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| pip install --find-links dist fastly-compute | |
| python -c "import fastly_compute; print('Successfully imported fastly_compute')" | |
| # Collect all artifacts for easy download | |
| collect-artifacts: | |
| name: Collect all build artifacts | |
| needs: [build-wheels, build-sdist] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: all-dist | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: ls -lR all-dist | |
| - name: Upload combined artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-wheels-and-sdist | |
| path: all-dist/* |