hot-dev 1.1.3

Official Rust SDK for the Hot Dev API
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: read

jobs:
  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    environment: crates-io
    permissions:
      contents: read
      id-token: write

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust
        run: rustup toolchain install stable --profile minimal --component rustfmt,clippy && rustup default stable

      - name: Validate release tag
        run: |
          VERSION=$(cargo metadata --no-deps --format-version 1 | python3 -c "import json,sys; print(json.load(sys.stdin)['packages'][0]['version'])")
          TAG_NAME="v${VERSION}"
          if [[ "${{ github.ref_name }}" != "$TAG_NAME" ]]; then
            echo "::error::Tag ${{ github.ref_name }} does not match Cargo.toml version (${TAG_NAME})"
            exit 1
          fi

      - name: Check formatting
        run: cargo fmt --check

      - name: Clippy
        run: cargo clippy --all-targets -- -D warnings

      - name: Test
        run: cargo test

      # Requires the trusted publisher to be configured on the crate's
      # crates.io settings (repo hot-dev/hot-rust, workflow release.yml,
      # environment crates-io).
      - name: Authenticate with crates.io
        uses: rust-lang/crates-io-auth-action@v1
        id: auth

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