sbus-rs 0.1.3

A no_std compatible SBUS protocol parser for embedded systems
Documentation
name: Release

permissions:
  contents: write  # Required to create releases
  
on:
  push:
    tags:
      - v[0-9]+.*  # Matches v1.0.0, v0.1.0 etc
  workflow_dispatch:  # Allow manual triggering
    inputs:
      tag:
        description: 'Tag to release (e.g., v0.1.3)'
        required: true
        type: string

jobs:
  test:
    name: Run full test suite
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: |
          cargo test --features blocking,std --bins --tests
          cargo test --no-default-features --features async,std --bins --tests

  publish:
    name: Publish to crates.io
    needs: [test]  # Only publish if tests pass
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      # Verify the tag matches the version in Cargo.toml
      - name: Verify version
        run: |
          CARGO_VERSION=$(cargo pkgid | cut -d'#' -f2)
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            TAG_VERSION=${{ inputs.tag }}
            TAG_VERSION=${TAG_VERSION#v}  # Remove 'v' prefix
          else
            TAG_VERSION=${GITHUB_REF#refs/tags/v}
          fi
          if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
            echo "Version mismatch: Cargo.toml ($CARGO_VERSION) != Tag ($TAG_VERSION)"
            exit 1
          fi

      # Create GitHub Release
      - name: Create GitHub Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
          body: |
            Release ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}

      # Publish to crates.io
      - name: Publish crate
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish