intermcp 0.3.0

Ultra-fast, safe Model Context Protocol (MCP) engine and multiplexing hub in pure Rust, built for Interlayer Blockchain and open for all
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  build-release:
    name: Build Binary (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact_name: intermcp
            asset_name: intermcp-${{ github.ref_name }}-x86_64-unknown-linux-gnu.tar.gz
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact_name: intermcp
            asset_name: intermcp-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact_name: intermcp
            asset_name: intermcp-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact_name: intermcp.exe
            asset_name: intermcp-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip

    steps:
      - uses: actions/checkout@v4

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

      - name: Build Binary
        run: cargo build --release --target ${{ matrix.target }}

      - name: Package (Unix)
        if: runner.os != 'Windows'
        run: |
          cd target/${{ matrix.target }}/release
          tar -czf ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }}
          cd ../../..

      - name: Package (Windows)
        if: runner.os == 'Windows'
        run: |
          Compress-Archive -Path target/${{ matrix.target }}/release/${{ matrix.artifact_name }} -DestinationPath ${{ matrix.asset_name }}

      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.asset_name }}
          path: ${{ matrix.asset_name }}

  publish-github-release:
    name: Publish GitHub Release
    needs: build-release
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4

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

      - name: Create Release
        uses: softprops/action-gh-release@v2
        with:
          files: release-assets/*
          generate_release_notes: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  publish-npm:
    name: Publish to npm
    needs: publish-github-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          registry-url: 'https://registry.npmjs.org'
      - name: Publish NPM package
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: |
          if [ -n "$NODE_AUTH_TOKEN" ]; then
            npm publish --access public || echo "Version already published to npm, skipping."
          else
            echo "NODE_AUTH_TOKEN not set, skipping npm publish"
          fi

  publish-pypi:
    name: Publish to PyPI
    needs: publish-github-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - name: Build and Publish PyPI package
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
        run: |
          if [ -n "$TWINE_PASSWORD" ]; then
            cd python
            pip install --upgrade build twine
            python -m build
            twine upload dist/* --non-interactive --skip-existing || echo "Version already published to PyPI, skipping."
          else
            echo "TWINE_PASSWORD not set, skipping PyPI publish"
          fi

  publish-crates-io:
    name: Publish to Crates.io
    needs: publish-github-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          if [ -n "$CARGO_REGISTRY_TOKEN" ]; then
            output=$(cargo publish 2>&1) || {
              if echo "$output" | grep -qi "already uploaded"; then
                echo "Version already uploaded to crates.io, skipping."
              else
                echo "$output"
                exit 1
              fi
            }
            echo "$output"
          else
            echo "CARGO_REGISTRY_TOKEN not set, skipping crates.io publish"
          fi

  publish-container:
    name: Publish Container to GitHub Packages (ghcr.io)
    needs: publish-github-release
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4

      - name: Log in to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract metadata (tags, labels)
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=semver,pattern={{version}}
            type=raw,value=latest

      - name: Build and push Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}