name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Run cargo test
run: cargo test --all-features
build-executables:
name: Build executables on ${{ matrix.os }}
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: rblhost-linux-x86_64
asset_name: rblhost-linux-x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: rblhost-windows-x86_64
asset_name: rblhost-windows-x86_64.exe
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: rblhost-macos-x86_64
asset_name: rblhost-macos-x86_64
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare binary (Unix)
if: runner.os != 'Windows'
run: |
cp target/${{ matrix.target }}/release/rblhost ${{ matrix.artifact_name }}
chmod +x ${{ matrix.artifact_name }}
- name: Prepare binary (Windows)
if: runner.os == 'Windows'
run: |
copy target\${{ matrix.target }}\release\rblhost.exe ${{ matrix.asset_name }}
- name: Upload executable artifact
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.asset_name }}