mcpkill 0.1.0

Universal MCP proxy — semantic cache + chunking to kill token waste
Documentation
name: Release

on:
  push:
    tags: ["v*"]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

permissions:
  contents: write   # needed to create GitHub Releases

jobs:
  # ── Build matrix ─────────────────────────────────────────────────────────────
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            cross: false

          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            cross: true   # uses `cross` for aarch64 cross-compilation

          - target: x86_64-apple-darwin
            os: macos-13
            cross: false

          - target: aarch64-apple-darwin
            os: macos-latest   # M1/M2/M3 runner
            cross: false

          - target: x86_64-pc-windows-msvc
            os: windows-latest
            cross: false

    steps:
      - uses: actions/checkout@v4

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

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }}

      - name: Install cross
        if: matrix.cross
        run: cargo install cross --locked

      - name: Build (native)
        if: "!matrix.cross"
        run: cargo build --release --target ${{ matrix.target }}

      - name: Build (cross)
        if: matrix.cross
        run: cross build --release --target ${{ matrix.target }}

      # ── Package ──────────────────────────────────────────────────────────────

      - name: Package (Unix)
        if: runner.os != 'Windows'
        shell: bash
        run: |
          BIN="target/${{ matrix.target }}/release/mcpkill"
          ARCHIVE="mcpkill-${{ matrix.target }}.tar.gz"
          tar -czf "$ARCHIVE" -C "$(dirname $BIN)" "$(basename $BIN)"
          sha256sum "$ARCHIVE" > "$ARCHIVE.sha256"
          echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV

      - name: Package (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          $bin  = "target\${{ matrix.target }}\release\mcpkill.exe"
          $archive = "mcpkill-${{ matrix.target }}.zip"
          Compress-Archive -Path $bin -DestinationPath $archive
          $hash = (Get-FileHash $archive -Algorithm SHA256).Hash.ToLower()
          "$hash  $archive" | Out-File "$archive.sha256" -Encoding ascii
          "ARCHIVE=$archive" | Out-File $env:GITHUB_ENV -Append

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.target }}
          path: |
            mcpkill-${{ matrix.target }}.*
          retention-days: 1

  # ── GitHub Release ────────────────────────────────────────────────────────────
  release:
    name: Create Release
    needs: build
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts
          merge-multiple: true

      - name: Extract changelog entry
        id: changelog
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          NOTES=$(awk "/^## \[$VERSION\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)
          echo "notes<<EOF" >> $GITHUB_OUTPUT
          echo "$NOTES" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          name: "mcpkill ${{ github.ref_name }}"
          body: ${{ steps.changelog.outputs.notes }}
          files: artifacts/**
          fail_on_unmatched_files: true

  # ── Publish to crates.io ─────────────────────────────────────────────────────
  publish:
    name: Publish to crates.io
    needs: release
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish
        run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}