name: Build
on:
push:
branches: [main, test-actions]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- os: windows-latest
target: x86_64-pc-windows-msvc
test: true
cross: false
- os: windows-latest
target: i686-pc-windows-msvc
test: true
cross: false
- os: macos-latest
target: x86_64-apple-darwin
test: true
cross: false
- os: macos-latest
target: aarch64-apple-darwin
test: false
cross: false
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
test: true
cross: false
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
test: true
cross: true
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
test: true
cross: true
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
test: true
cross: false
steps:
- name: Git config
if: ${{ matrix.config.os == 'windows-latest' }}
run: git config --global core.autocrlf input
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install musl tools
if: ${{ matrix.config.target == 'x86_64-unknown-linux-musl' }}
run: sudo apt-get install musl-tools musl-dev
- name: Install rust
run: rustup update && rustup target add ${{ matrix.config.target }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.config.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install cross
if: ${{ matrix.config.cross }}
run: |
cargo install cross
- name: Build
run: ${{ matrix.config.cross && 'cross' || 'cargo' }} build --release --target ${{ matrix.config.target }}
- name: Test
if: ${{ matrix.config.test }}
run: ${{ matrix.config.cross && 'cross' || 'cargo' }} test --release --target ${{ matrix.config.target }}