model-context-protocol 0.2.2

A Rust implementation of the Model Context Protocol (MCP) for AI tool integration
Documentation
name: Release

on:
  push:
    branches:
      - 'release/v*'
    tags:
      - 'v*'

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build & Test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

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

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2

      - name: Update Cargo.toml versions
        shell: pwsh
        run: |
          $result = ./scripts/Get-Version.ps1
          Write-Host "Building version: $($result.Version)"
          ./scripts/Get-Version.ps1 -UpdateCargo -TagOnly

      - name: Build
        run: cargo build --workspace --all-features

      - name: Test
        run: cargo test --workspace --all-features

  publish:
    name: Publish to crates.io
    needs: build
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

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

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2

      - name: Calculate version
        id: version
        shell: pwsh
        run: |
          $result = ./scripts/Get-Version.ps1
          echo "version=$($result.Version)" >> $env:GITHUB_OUTPUT
          echo "is_prerelease=$($result.IsPrerelease.ToString().ToLower())" >> $env:GITHUB_OUTPUT
          Write-Host "Publishing version: $($result.Version)"
          ./scripts/Get-Version.ps1 -UpdateCargo

      - name: Publish model-context-protocol-macros
        run: cargo publish -p model-context-protocol-macros --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty
        continue-on-error: true

      - name: Wait for crates.io index
        run: sleep 30

      - name: Publish model-context-protocol
        run: cargo publish -p model-context-protocol --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          name: v${{ steps.version.outputs.version }}
          generate_release_notes: true
          draft: false
          prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }}