Update release.yaml #8
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: Release | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| env: | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| tests: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| prefix-key: "v0-rust" | |
| cache-workspace-crates: "true" | |
| - name: Run tests | |
| run: cargo test --package ocli | |
| build: | |
| name: Release - ${{ matrix.platform.os_name }} | |
| needs: | |
| - tests | |
| if: | | |
| github.ref == 'refs/heads/main' || | |
| github.event_name == 'workflow_dispatch' || | |
| startsWith(github.ref, 'refs/tags/') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - os_name: Linux-x86_64 | |
| os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| bin: ocli | |
| name: ocli-manylinux-x86_64.zip | |
| - os_name: macOS-aarch64 | |
| os: macOS-latest | |
| target: aarch64-apple-darwin | |
| bin: ocli | |
| name: ocli-macos-aarch64.zip | |
| runs-on: ${{ matrix.platform.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.platform.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| prefix-key: "v0-rust" | |
| - name: Build Linux binary (maturin) | |
| if: matrix.platform.os_name == 'Linux-x86_64' | |
| run: | | |
| docker run --rm \ | |
| -v $(pwd):/io \ | |
| --entrypoint /usr/bin/bash \ | |
| ghcr.io/pyo3/maturin:latest -c \ | |
| "yum install -y openssl-devel python3-devel && cd /io && cargo build --locked --release --target ${{ matrix.platform.target }} && strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} && cd target/${{ matrix.platform.target }}/release && zip ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}" | |
| - name: Build macOS binary | |
| if: matrix.platform.os_name == 'macOS-aarch64' | |
| run: | | |
| cargo build --locked --release --target ${{ matrix.platform.target }} | |
| strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | |
| cd target/${{ matrix.platform.target }}/release | |
| zip ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform.os_name }}-binary | |
| path: ${{ matrix.platform.name }} | |
| build-wheel: | |
| name: Wheel - ${{ matrix.platform.os_name }} | |
| needs: | |
| - tests | |
| if: | | |
| github.ref == 'refs/heads/main' || | |
| github.event_name == 'workflow_dispatch' || | |
| startsWith(github.ref, 'refs/tags/') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| # Linux wheel | |
| - os_name: Linux-x86_64 | |
| os: ubuntu-latest | |
| # macOS wheel (ARM) | |
| - os_name: macOS-aarch64 | |
| os: macOS-latest | |
| runs-on: ${{ matrix.platform.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Create virtual environment and install maturin | |
| run: | | |
| python -m venv .venv | |
| source .venv/bin/activate | |
| pip install maturin | |
| - name: Build Linux wheel | |
| run: | | |
| docker run --rm \ | |
| -v $(pwd):/io \ | |
| --entrypoint /usr/bin/bash \ | |
| ghcr.io/pyo3/maturin -c \ | |
| "yum install -y openssl-devel && maturin build --release --manifest-path src/pyocli/Cargo.toml --out target/wheels" | |
| if: matrix.platform.os_name == 'Linux-x86_64' | |
| - name: Build macOS wheel | |
| run: | | |
| source .venv/bin/activate | |
| pip install maturin[patchelf] | |
| maturin build --release \ | |
| --manifest-path src/pyocli/Cargo.toml \ | |
| --target aarch64-apple-darwin \ | |
| --out target/wheels | |
| if: matrix.platform.os_name == 'macOS-aarch64' | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform.os_name }}-wheel | |
| path: target/wheels/*.whl | |
| release: | |
| name: Create Release | |
| needs: | |
| - build | |
| - build-wheel | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: | | |
| echo "=== Artifacts ===" | |
| ls -la artifacts/ | |
| find artifacts/ -type f -name "*.zip" -o -name "*.whl" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| draft: true | |
| files: | | |
| artifacts/*.zip | |
| artifacts/*.whl |