barbed 0.0.2

Twitch Helix, EventSub, OAuth, and signing helpers
Documentation
name: Publish

on:
  push:
    tags:
      - "v*.*.*"

permissions:
  contents: write
  id-token: write

concurrency:
  group: publish-${{ github.ref }}
  cancel-in-progress: false

env:
  CARGO_TERM_COLOR: always

jobs:
  publish:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Validate tag and manifest version
        id: release_meta
        env:
          TAG_NAME: ${{ github.ref_name }}
        run: |
          set -euo pipefail

          VERSION="${TAG_NAME#v}"
          if [ "$VERSION" = "$TAG_NAME" ]; then
            echo "Expected a v-prefixed tag, got '$TAG_NAME'." >&2
            exit 1
          fi

          MANIFEST_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)"
          if [ -z "$MANIFEST_VERSION" ]; then
            echo "Could not read package version from Cargo.toml." >&2
            exit 1
          fi

          if [ "$VERSION" != "$MANIFEST_VERSION" ]; then
            echo "Tag version '$VERSION' does not match Cargo.toml version '$MANIFEST_VERSION'." >&2
            exit 1
          fi

          echo "version=$VERSION" >> "$GITHUB_OUTPUT"

      - name: Install stable toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
          targets: wasm32-unknown-unknown

      - name: Restore Rust cache
        uses: Swatinem/rust-cache@v2

      - name: Lint
        run: cargo clippy --all-targets --all-features --locked -- -D warnings

      - name: Test all features
        run: cargo test --all-features --locked

      - name: Build Cloudflare Worker feature for wasm
        run: cargo build --features cloudflare-worker --target wasm32-unknown-unknown --locked

      - name: Verify packaging
        run: cargo package --locked

      - name: Check REUSE compliance
        uses: fsfe/reuse-action@v6

      - name: Authenticate with crates.io
        id: auth
        uses: rust-lang/crates-io-auth-action@v1

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
        run: cargo publish --locked

      - name: Create GitHub release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.ref_name }}
          name: barbed v${{ steps.release_meta.outputs.version }}
          generate_release_notes: true