a3s-orm 0.3.1

A type-safe, executor-neutral SQL query builder for Rust
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -Dwarnings

jobs:
  release:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:17-alpine
        env:
          POSTGRES_PASSWORD: postgres
          POSTGRES_DB: a3s_orm
        ports:
          - 5432:5432
        options: >-
          --health-cmd "pg_isready -U postgres -d a3s_orm"
          --health-interval 5s
          --health-timeout 5s
          --health-retries 10
    env:
      A3S_ORM_POSTGRES_URL: postgres://postgres:postgres@127.0.0.1:5432/a3s_orm
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt
      - uses: Swatinem/rust-cache@v2
      - name: Verify tag matches crate version
        shell: bash
        run: |
          version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)"
          test "${GITHUB_REF_NAME}" = "v${version}"
      - run: cargo fmt --all -- --check
      - run: cargo test --all-features
      - run: cargo clippy --all-targets --all-features -- -D warnings
      - run: cargo package --locked
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        shell: bash
        run: |
          set -euo pipefail
          version="${GITHUB_REF_NAME#v}"
          if curl -fsSL "https://crates.io/api/v1/crates/a3s-orm/${version}" >/dev/null 2>&1; then
            echo "a3s-orm ${version} already exists on crates.io; skipping publish."
          else
            cargo publish --locked
          fi
      - name: Create or update GitHub release
        env:
          GH_TOKEN: ${{ github.token }}
        shell: bash
        run: |
          set -euo pipefail
          asset="target/package/a3s-orm-${GITHUB_REF_NAME#v}.crate"
          if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
            gh release upload "${GITHUB_REF_NAME}" "${asset}" --clobber
          else
            gh release create "${GITHUB_REF_NAME}" "${asset}" \
              --title "a3s-orm ${GITHUB_REF_NAME}" \
              --generate-notes \
              --verify-tag
          fi