|
| 1 | +name: Build Rust Crates |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - "rust/**/*.rs" |
| 7 | + - "rust/Cargo.toml" |
| 8 | + - "rust/Cargo.lock" |
| 9 | + - "noxfile.py" |
| 10 | + - ".github/workflows/build-rust.yml" |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + - master |
| 15 | + paths: |
| 16 | + - "rust/**/*.rs" |
| 17 | + - "rust/Cargo.toml" |
| 18 | + - "rust/Cargo.lock" |
| 19 | + - "noxfile.py" |
| 20 | + - ".github/workflows/build-rust.yml" |
| 21 | + |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-rust: |
| 26 | + name: Build Rust Crates |
| 27 | + runs-on: {{ "${{ matrix.platform.runner }}" }} |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + platform: |
| 31 | + - runner: ubuntu-latest |
| 32 | + target: x86_64-unknown-linux-gnu |
| 33 | + - runner: ubuntu-latest |
| 34 | + target: x86_64-unknown-linux-musl |
| 35 | + - runner: ubuntu-latest |
| 36 | + target: aarch64-unknown-linux-gnu |
| 37 | + - runner: ubuntu-latest |
| 38 | + target: aarch64-unknown-linux-musl |
| 39 | + - runner: macos-latest |
| 40 | + target: x86_64-apple-darwin |
| 41 | + - runner: macos-latest |
| 42 | + target: aarch64-apple-darwin |
| 43 | + - runner: windows-latest |
| 44 | + target: x86_64-pc-windows-msvc |
| 45 | + - runner: windows-latest |
| 46 | + target: i686-pc-windows-msvc |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout code |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Set up Rust |
| 53 | + uses: dtolnay/rust-toolchain@stable |
| 54 | + with: |
| 55 | + targets: {{ "${{ matrix.platform.target }}" }} |
| 56 | + |
| 57 | + - name: Set up cross-compilation toolchain (Linux) |
| 58 | + if: contains(matrix.platform.target, 'linux') |
| 59 | + run: | |
| 60 | + sudo apt-get update |
| 61 | + sudo apt-get install -y gcc-multilib |
| 62 | + if [[ "{{ "${{ matrix.platform.target }}" }}" == *"aarch64"* ]]; then |
| 63 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 64 | + fi |
| 65 | + if [[ "{{ "${{ matrix.platform.target }}" }}" == *"musl"* ]]; then |
| 66 | + sudo apt-get install -y musl-tools |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Set up uv |
| 70 | + uses: astral-sh/setup-uv@v6 |
| 71 | + |
| 72 | + - name: Set up Python |
| 73 | + uses: actions/setup-python@v5 |
| 74 | + with: |
| 75 | + python-version-file: ".github/workflows/.python-version" |
| 76 | + |
| 77 | + - name: Build Rust crates for target |
| 78 | + run: | |
| 79 | + cd rust |
| 80 | + cargo build --release --target {{ "${{ matrix.platform.target }}" }} |
| 81 | +
|
| 82 | + - name: Upload Rust build artifacts |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: rust-artifacts-{{ "${{ matrix.platform.target }}" }} |
| 86 | + path: rust/target/{{ "${{ matrix.platform.target }}" }}/release/ |
| 87 | + retention-days: 7 |
0 commit comments