name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
jobs:
publish:
name: publish
runs-on: ubuntu-latest
environment: crates-io
steps:
- uses: actions/checkout@v4
- name: Install libudev (serialport build dep)
run: sudo apt-get update && sudo apt-get install -y libudev-dev pkg-config
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Verify the tag matches Cargo.toml
if: startsWith(github.ref, 'refs/tags/v')
run: |
tag="${GITHUB_REF##*/v}"
ver=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
if [ "$tag" != "$ver" ]; then
echo "Tag $tag does not match Cargo.toml version $ver" >&2
exit 1
fi
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo test --all-features
- name: doc
env:
RUSTDOCFLAGS: "-D warnings"
run: cargo doc --no-deps --all-features
- run: cargo publish --all-features
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}