chess-vector-engine 0.5.1

Open source chess engine with hybrid vector-based position analysis, advanced tactical search, and NNUE neural network evaluation
Documentation
name: 🚀 Release

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_TERM_COLOR: always

jobs:
  create-release:
    name: 📦 Create Release
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create_release.outputs.upload_url }}
    steps:
    - name: 📥 Checkout code
      uses: actions/checkout@v4

    - name: 🏷️ Get tag
      id: tag
      run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

    - name: 📝 Generate changelog
      id: changelog  
      run: |
        # Extract changelog from tag message or generate from commits
        if git tag -l --format='%(contents)' ${{ steps.tag.outputs.tag }} | grep -q "^## "; then
          CHANGELOG=$(git tag -l --format='%(contents)' ${{ steps.tag.outputs.tag }})
        else
          CHANGELOG="## Changes in ${{ steps.tag.outputs.tag }}"$'\n\n'"$(git log --pretty=format:'- %s' $(git describe --tags --abbrev=0 HEAD^)..HEAD)"
        fi
        echo "changelog<<EOF" >> $GITHUB_OUTPUT
        echo "$CHANGELOG" >> $GITHUB_OUTPUT
        echo "EOF" >> $GITHUB_OUTPUT

    - name: 🎉 Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ steps.tag.outputs.tag }}
        release_name: Chess Vector Engine ${{ steps.tag.outputs.tag }}
        body: ${{ steps.changelog.outputs.changelog }}
        draft: false
        prerelease: ${{ contains(steps.tag.outputs.tag, '-') }}

  build-binaries:
    name: 🏗️ Build Release Binaries
    needs: create-release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            name: linux-x64
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            name: linux-x64-musl
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            name: windows-x64
          - os: macos-latest
            target: x86_64-apple-darwin
            name: macos-x64
          - os: macos-latest
            target: aarch64-apple-darwin
            name: macos-arm64

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

    - name: 🦀 Setup Rust
      uses: dtolnay/rust-toolchain@stable
      with:
        targets: ${{ matrix.target }}

    - name: 📦 Install cross (Linux only)
      if: matrix.os == 'ubuntu-latest'
      run: cargo install cross --git https://github.com/cross-rs/cross

    - name: 🏗️ Build release binary
      run: |
        if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
          cross build --release --target ${{ matrix.target }} --bins
        else
          cargo build --release --target ${{ matrix.target }} --bins
        fi

    - name: 📦 Package binaries
      run: |
        mkdir -p dist
        if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
          cp target/${{ matrix.target }}/release/uci_engine.exe dist/
          cp target/${{ matrix.target }}/release/demo.exe dist/
          cp target/${{ matrix.target }}/release/analyze.exe dist/
          cp target/${{ matrix.target }}/release/benchmark.exe dist/
          cd dist && zip -r ../chess-vector-engine-${{ matrix.name }}.zip *
        else
          cp target/${{ matrix.target }}/release/uci_engine dist/
          cp target/${{ matrix.target }}/release/demo dist/
          cp target/${{ matrix.target }}/release/analyze dist/
          cp target/${{ matrix.target }}/release/benchmark dist/
          cd dist && tar -czf ../chess-vector-engine-${{ matrix.name }}.tar.gz *
        fi

    - name: 📤 Upload Release Asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ needs.create-release.outputs.upload_url }}
        asset_path: ./chess-vector-engine-${{ matrix.name }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
        asset_name: chess-vector-engine-${{ matrix.name }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
        asset_content_type: application/octet-stream

  publish-crate:
    name: 📦 Publish to Crates.io
    needs: [create-release, build-binaries]
    runs-on: ubuntu-latest
    steps:
    - name: 📥 Checkout code
      uses: actions/checkout@v4

    - name: 🦀 Setup Rust
      uses: dtolnay/rust-toolchain@stable

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

    - name: 📦 Package and verify
      run: |
        cargo package --allow-dirty
        cargo publish --dry-run

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

  docker-build:
    name: 🐳 Build Docker Images
    needs: create-release
    runs-on: ubuntu-latest
    steps:
    - name: 📥 Checkout code
      uses: actions/checkout@v4

    - name: 🏷️ Get tag
      id: tag
      run: echo "tag=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

    - name: 🐳 Set up Docker Buildx
      uses: docker/setup-buildx-action@v3

    - name: 🔐 Login to DockerHub
      uses: docker/login-action@v3
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_TOKEN }}

    - name: 🏗️ Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        platforms: linux/amd64,linux/arm64
        push: true
        tags: |
          chessvector/chess-vector-engine:latest
          chessvector/chess-vector-engine:${{ steps.tag.outputs.tag }}
        cache-from: type=gha
        cache-to: type=gha,mode=max

  update-docs:
    name: 📚 Update Documentation
    needs: create-release
    runs-on: ubuntu-latest
    steps:
    - name: 📥 Checkout code
      uses: actions/checkout@v4

    - name: 🦀 Setup Rust
      uses: dtolnay/rust-toolchain@stable

    - name: 📚 Build documentation
      run: cargo doc --all-features --no-deps

    - name: 📤 Deploy docs
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./target/doc
        cname: docs.chessvector.ai

  notify:
    name: 📢 Notify Release
    needs: [create-release, build-binaries, publish-crate]
    runs-on: ubuntu-latest
    if: always()
    steps:
    - name: 🏷️ Get tag
      id: tag
      run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

    - name: ✅ Success notification
      if: needs.create-release.result == 'success' && needs.build-binaries.result == 'success' && needs.publish-crate.result == 'success'
      run: |
        echo "🎉 Release ${{ steps.tag.outputs.tag }} completed successfully!"
        echo "- ✅ GitHub release created"
        echo "- ✅ Binaries built and uploaded"
        echo "- ✅ Published to crates.io"

    - name: ❌ Failure notification
      if: needs.create-release.result == 'failure' || needs.build-binaries.result == 'failure' || needs.publish-crate.result == 'failure'
      run: |
        echo "❌ Release ${{ steps.tag.outputs.tag }} failed!"
        echo "- Create release: ${{ needs.create-release.result }}"
        echo "- Build binaries: ${{ needs.build-binaries.result }}"
        echo "- Publish crate: ${{ needs.publish-crate.result }}"