nusadb 0.1.0

Fast, stable native Rust driver and ORM for NusaDB (Nusa Wire Protocol 1.1).
Documentation
name: Release

# Publishes the `nusadb` crate to crates.io.
#
#   git tag v0.1.0 && git push origin v0.1.0
#
# Requires the CARGO_REGISTRY_TOKEN secret (a crates.io API token with publish-new +
# publish-update scope).
#
# The crate was originally named `turbo`, which is taken on crates.io by an unrelated 2017
# package. `nusadb` matches what this driver is called on npm, PyPI and Packagist.

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@v2

      - name: Verify the crate version matches the tag
        run: |
          tag="${GITHUB_REF_NAME#v}"
          crate="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')"
          if [ "$tag" != "$crate" ]; then
            echo "::error::tag v$tag does not match Cargo.toml version $crate"
            exit 1
          fi
          echo "releasing nusadb@$crate"

      - name: Format and clippy
        run: |
          cargo fmt --all --check
          for features in "" "tls" "async" "async-tls"; do
            cargo clippy --all-targets --no-default-features --features "${features}" -- -D warnings
          done

      # Gate the release on what is verifiable without a live server: the integration tests
      # skip when they cannot find a `nusadb-server` binary, which this repo does not ship.
      - name: Test
        run: cargo test --all-features

      - name: Package
        run: cargo package

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

  github-release:
    needs: publish
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
      - name: Create GitHub Release
        env:
          GH_TOKEN: ${{ github.token }}
        run: gh release create "${GITHUB_REF_NAME}" --generate-notes --verify-tag