apalis-postgres 1.0.0-rc.7

Background task processing for rust using apalis and postgres
Documentation
name: Release and Publish

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:
    inputs:
      version:
        description: 'Version to publish (without v prefix)'
        required: true
        type: string

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    uses: ./.github/workflows/ci.yml
  validate:
    name: Validate Release
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.version.outputs.version }}
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6

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

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

      - name: Extract version
        id: version
        run: |
          if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
            VERSION="${{ github.event.inputs.version }}"
          else
            VERSION=${GITHUB_REF#refs/tags/v}
          fi
          echo "version=$VERSION" >> $GITHUB_OUTPUT
          echo "Extracted version: $VERSION"

      - name: Verify version matches Cargo.toml
        run: |
          CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
          if [[ "$CARGO_VERSION" != "${{ steps.version.outputs.version }}" ]]; then
            echo "Version mismatch: Cargo.toml has $CARGO_VERSION, but release is ${{ steps.version.outputs.version }}"
            exit 1
          fi

  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: [test, validate]
    environment: release
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6

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

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

      - name: Login to crates.io
        run: cargo login ${{ secrets.CRATES_IO_TOKEN }}

      - name: Publish to crates.io
        run: cargo publish