marlin-binary-transfer 0.1.2

Host-side implementation of Marlin's Binary File Transfer Mark II protocol for SD-card upload to 3D printers.
Documentation
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

      # Re-run the full feature matrix + clippy + fmt + docs before
      # publishing. Catches the case where the release tag was cut
      # from a green commit but Cargo.lock churn between branches
      # changed something.
      - 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 }}