name: Rust
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches: [ "master", "dbg-action" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
pull-requests: write
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
toolchain: [stable, nightly]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
features: --all-features
- os: windows-latest
target: x86_64-pc-windows-msvc
features: --features entra-id
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install system dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt-get install -y libudev-dev pkg-config
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
components: clippy
toolchain: ${{ matrix.toolchain }}
override: true
- name: Clippy
run: cargo clippy --all-targets ${{matrix.features}} -- --deny warnings
- name: Build
run: cargo build ${{matrix.features}}
- name: Run tests
run: cargo test ${{matrix.features}} -- --test-threads=1
create-releases:
name: Create releases
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install system dependencies
run: |
sudo apt update
sudo apt-get install -y libudev-dev pkg-config
- name: Build and Install Binary
run: |
mkdir -p ${{github.workspace}}/install
cargo install --path '${{github.workspace}}' --root '${{github.workspace}}/install' --all-features --locked
shell: bash
- name: Get version from Cargo.toml
id: get-version
run: |
version="$(grep '^version' Cargo.toml | head -n1 | sed 's/version\s*=\s*"\(.*\)"/\1/')"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create and push tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.get-version.outputs.version }}
- name: Rename artifacts
run: |
mv "${{github.workspace}}/install/bin/shvbroker" "${{github.workspace}}/install/bin/shvbroker-${{ steps.get-version.outputs.version }}"
mv "${{github.workspace}}/install/bin/shvbroker_migrate_legacy" "${{github.workspace}}/install/bin/shvbroker_migrate_legacy-${{ steps.get-version.outputs.version }}"
- name: Release
uses: softprops/action-gh-release@v3
with:
name: shvbroker ${{ steps.get-version.outputs.version }}
tag_name: ${{ steps.get-version.outputs.version }}
fail_on_unmatched_files: true
make_latest: true
body: |
shvbroker ${{ steps.get-version.outputs.version }}
If you find any bugs, please report them to the repository's issue tracker.
files: |
${{github.workspace}}/install/bin/shvbroker*${{ steps.get-version.outputs.version }}*
coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Install system dependencies
run: |
sudo apt update
sudo apt-get install -y libudev-dev pkg-config
- name: Generate coverage
uses: silicon-heaven/rust-pycobertura-action@v4.1.0
with:
project_name: shvbroker