wip #50
This file contains 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: Test and Build | |
on: [push, pull_request] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Use cached dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: "${{ hashFiles('**/Cargo.lock') }}" | |
shared-key: "shared" | |
- name: Install build dependencies - Rustup | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y | |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
- name: Check style | |
run: cargo fmt --check | |
- name: Check clippy | |
run: cargo clippy --all-features --locked | |
- name: Build | |
run: cargo test --all-features --verbose --locked --no-run | |
- name: Test | |
run: cargo test --all-features --verbose --locked -- --nocapture | |
build: | |
needs: test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: macos-latest | |
TARGET: aarch64-apple-darwin | |
- os: macos-latest | |
TARGET: x86_64-apple-darwin | |
- os: ubuntu-latest | |
TARGET: arm-unknown-linux-musleabihf | |
- os: ubuntu-latest | |
TARGET: aarch64-unknown-linux-musl | |
- os: ubuntu-latest | |
TARGET: armv7-unknown-linux-musleabihf | |
- os: ubuntu-latest | |
TARGET: x86_64-unknown-linux-musl | |
- os: windows-latest | |
TARGET: x86_64-pc-windows-msvc | |
EXTENSION: .exe | |
steps: | |
- name: Building ${{ matrix.TARGET }} | |
run: echo "${{ matrix.TARGET }}" | |
- uses: actions/checkout@v4 | |
- name: Use cached dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: "${{ matrix.os }}-${{ matrix.TARGET }}-${{ hashFiles('**/Cargo.lock') }}" | |
shared-key: "shared" | |
- name: Install build dependencies - Rustup | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --profile minimal --target ${{ matrix.TARGET }} -y | |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
- name: Install build dependencies - Cross | |
if: ${{ contains(matrix.TARGET, 'linux') }} | |
run: cargo install cross | |
- name: Building for ${{ matrix.os }} ${{ matrix.target }} (${{ matrix.EXTENSION }}) | |
if: ${{ contains(matrix.TARGET, 'linux') }} | |
run: cross build --release --locked --target ${{matrix.target}} --verbose | |
- name: Building for ${{ matrix.os }} ${{ matrix.target }} (${{ matrix.EXTENSION }}) | |
if: ${{ !contains(matrix.TARGET, 'linux') }} | |
run: cargo build --release --locked --target ${{matrix.target}} --verbose | |
- name: Prepare files | |
run: cp target/${{ matrix.TARGET }}/release/${{ github.event.repository.name }}${{ matrix.EXTENSION }} ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
path: ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
- uses: svenstaro/upload-release-action@v2 | |
name: Upload binaries to release | |
if: ${{ github.event_name == 'push' }} | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
asset_name: ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
tag: ${{ github.ref }} | |
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
overwrite: true |