sqlx-pool-router 0.2.0

Lightweight SQLx PostgreSQL connection pool routing for primary/replica separation
Documentation
name: Release

on:
  release:
    types: [published]
  workflow_dispatch:

jobs:
  test:
    name: Test before publish
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_PASSWORD: password
          POSTGRES_DB: test
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

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

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

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}

      - name: Run tests
        env:
          DATABASE_URL: postgresql://postgres:password@localhost:5432/test
        run: cargo test --all-features --verbose

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

      - name: Run clippy
        run: cargo clippy --all-features -- -D warnings

  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: test
    if: github.event_name == 'release' && !github.event.release.prerelease

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

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

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