qdrant-datafusion 0.1.1

Qdrant integration for Apache DataFusion
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:
    inputs:
      skip_publish:
        description: 'Create release only'
        default: false
        required: false
        type: boolean
      version:
        description: 'Version to release (e.g., 0.1.5)'
        required: false
        type: string

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  RUSTFLAGS: '-C debuginfo=line-tables-only -C incremental=false'

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

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

      - name: Verify version consistency
        run: |
          # Determine version based on trigger type
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            if [ -n "${{ inputs.version }}" ]; then
              # Use provided version input
              VERSION="${{ inputs.version }}"
              echo "Using provided version: $VERSION"
            else
              # Extract version from Cargo.toml
              VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
              echo "Using version from Cargo.toml: $VERSION"
            fi
          else
            # Extract version from tag (push trigger)
            VERSION=${GITHUB_REF#refs/tags/v}
            echo "Using version from tag: $VERSION"
          fi

          echo "VERSION=$VERSION" >> $GITHUB_ENV

          # Check that Cargo.toml has the correct version
          CARGO_VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
          if [ "$CARGO_VERSION" != "$VERSION" ]; then
            echo "Error: Cargo.toml version ($CARGO_VERSION) does not match expected version ($VERSION)"
            echo "Please ensure versions are consistent"
            exit 1
          fi

      - name: Verify publish
        if: ${{ inputs.skip_publish == false }}
        run: |
          cargo publish --dry-run -p qdrant-datafusion --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

      - name: Publish to crates.io
        if: ${{ inputs.skip_publish == false }}
        run: |
          cargo publish -p qdrant-datafusion --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

      - name: Extract release notes
        run: |
          # Check if RELEASE_NOTES.md exists (from the PR)
          if [ -f "RELEASE_NOTES.md" ]; then
            cp RELEASE_NOTES.md release_notes_for_tag.md
          else
            # Generate release notes for this tag if not present
            echo "# Release v$VERSION" > release_notes_for_tag.md
            echo "" >> release_notes_for_tag.md
            echo "This release was published from tag v$VERSION" >> release_notes_for_tag.md
          fi

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          body_path: release_notes_for_tag.md
          draft: false
          prerelease: ${{ contains(env.VERSION, '-rc') || contains(env.VERSION, '-beta') || contains(env.VERSION, '-alpha') }}
          tag_name: v${{ env.VERSION }}
          name: Release v${{ env.VERSION }}