mindkit 0.1.0

A generic sequential thinking toolkit for AI reasoning systems
Documentation
name: Publish

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_TERM_COLOR: always

jobs:
  validate:
    name: Validate before publish
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-publish-
            ${{ runner.os }}-cargo-
      
      - name: Check version matches tag
        run: |
          CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
          TAG_VERSION=${GITHUB_REF#refs/tags/v}
          if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
            echo "Error: Cargo.toml version ($CARGO_VERSION) does not match tag version ($TAG_VERSION)"
            exit 1
          fi
      
      - name: Run tests
        run: cargo test --all-features
      
      - name: Check formatting
        run: cargo fmt -- --check
      
      - name: Run clippy
        run: cargo clippy -- -D warnings
      
      - name: Build documentation
        run: cargo doc --no-deps
        env:
          RUSTDOCFLAGS: -D warnings

  publish:
    name: Publish to crates.io
    needs: validate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-publish-
            ${{ runner.os }}-cargo-
      
      - name: Dry run publish
        run: cargo publish --dry-run
      
      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  create-release:
    name: Create GitHub Release
    needs: publish
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
      
      - name: Extract version
        id: extract_version
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          echo "version=$VERSION" >> $GITHUB_OUTPUT
      
      - name: Generate changelog
        id: changelog
        run: |
          # Get the previous tag
          PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
          
          if [ -z "$PREV_TAG" ]; then
            echo "First release" > changelog.txt
          else
            git log $PREV_TAG..HEAD --pretty=format:"- %s" > changelog.txt
          fi
          
          echo "changelog<<EOF" >> $GITHUB_OUTPUT
          cat changelog.txt >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT
      
      - name: Create Release
        uses: softprops/action-gh-release@v2
        with:
          name: MindKit v${{ steps.extract_version.outputs.version }}
          body: |
            # MindKit v${{ steps.extract_version.outputs.version }}
            
            A Rust library for structured sequential thinking and reasoning patterns.
            
            ## What's Changed
            ${{ steps.changelog.outputs.changelog }}
            
            ## Installation
            ```toml
            [dependencies]
            mindkit = "${{ steps.extract_version.outputs.version }}"
            ```
            
            ## Documentation
            - [Crates.io](https://crates.io/crates/mindkit)
            - [Docs.rs](https://docs.rs/mindkit)
            - [Repository](https://github.com/DevOpsDali/mindkit)
          draft: false
          prerelease: false