ndatafusion 0.1.1

Extensions and support for linear algebra in DataFusion
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:
    inputs:
      skip_publish:
        description: 'Create GitHub release only'
        default: false
        required: false
        type: boolean
      verify_publish:
        description: 'Verify publish with --dry-run before publish'
        default: false
        required: false
        type: boolean
      version:
        description: 'Version to release (for example, 0.1.5)'
        required: false
        type: string

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always
  CARGO_INCREMENTAL: '0'
  RUST_BACKTRACE: 1
  RUSTFLAGS: '-C debuginfo=line-tables-only'

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

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

      - name: Determine release version
        run: |
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            if [ -n "${{ inputs.version }}" ]; then
              VERSION="${{ inputs.version }}"
            else
              VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
            fi
          else
            VERSION=${GITHUB_REF#refs/tags/v}
          fi

          echo "VERSION=$VERSION" >> "$GITHUB_ENV"
          echo "Using version: $VERSION"

      - name: Verify version consistency
        run: |
          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)"
            exit 1
          fi

      - name: Note current publication posture
        run: |
          if grep -Eq '^datafusion = \{.*git *= *"' Cargo.toml; then
            echo "DataFusion is still sourced from git; this workflow creates a GitHub release only."
          else
            echo "Cargo.toml is on the crates.io DataFusion line; this workflow can publish to crates.io when CARGO_REGISTRY_TOKEN is configured."
          fi

      - name: Verify release packaging
        run: cargo package --no-default-features

      - name: Ensure crates.io token is configured
        if: ${{ inputs.skip_publish != true }}
        run: |
          if [ -z "${{ secrets.CARGO_REGISTRY_TOKEN }}" ]; then
            echo "Error: CARGO_REGISTRY_TOKEN secret is not configured"
            exit 1
          fi

      - name: Verify publish
        if: ${{ inputs.skip_publish != true && inputs.verify_publish == true }}
        run: cargo publish --dry-run --no-default-features --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

      - name: Publish ndatafusion to crates.io
        if: ${{ inputs.skip_publish != true }}
        run: cargo publish --no-default-features --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

      - name: Extract release notes
        run: |
          if [ -f "RELEASE_NOTES.md" ]; then
            cp RELEASE_NOTES.md release_notes_for_tag.md
          else
            {
              echo "# Release v$VERSION"
              echo
              echo "Tagged release for ndatafusion v$VERSION."
            } > release_notes_for_tag.md
          fi

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        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 }}