connectrpc-workers 0.2.0

ConnectRPC ClientTransport implementations backed by the Cloudflare Workers fetch APIs (service bindings + global fetch).
Documentation
name: build_and_test

on:
  push:
    branches:
      - main
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+*'
  pull_request: {}

env:
  CARGO_TERM_COLOR: always

jobs:
  fmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --all -- --check

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo clippy --all-targets --all-features --locked -- -D warnings

  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      # Tests target the host: URI parsing + transport construction. The
      # JS-bound bits (FetcherTransport::send, FetchTransport::send) are
      # exercised end-to-end by the example at examples/multi (vitest +
      # miniflare against compiled wasm bundles), not here.
      - run: cargo test --locked

  # The whole point of the crate is to compile under wasm32-unknown-unknown
  # — the target Cloudflare Workers actually run. Breaks in the host build
  # are caught by `test`; this catches `Send`/`Sync` regressions, missing
  # `cfg`-gates, and unintended pulls of std-only deps.
  wasm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --target wasm32-unknown-unknown --locked

  msrv:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@1.88
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --locked

  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          shared-key: audit
          cache-directories: |
            ~/.cargo/advisory-db
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-audit
      - run: cargo audit --deny warnings

  # Publishes to crates.io when a `v*.*.*` tag is pushed. Gated on every
  # other job passing so a green tag build is required to ship.
  publish:
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/v')
    needs: [fmt, clippy, test, wasm, msrv, audit]
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Verify tag matches Cargo.toml version
        run: |
          TAG="${GITHUB_REF#refs/tags/v}"
          VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "connectrpc-workers") | .version')
          if [ "$TAG" != "$VERSION" ]; then
            echo "::error::Tag v$TAG does not match Cargo.toml version $VERSION"
            exit 1
          fi
      - run: cargo publish --locked --dry-run
      - run: cargo publish --locked
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
      - name: Create GitHub Release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          TAG="${GITHUB_REF#refs/tags/}"
          gh release create "$TAG" \
            --title "$TAG" \
            --notes "See [ChangeLog.md](https://github.com/${{ github.repository }}/blob/main/ChangeLog.md) for release notes."