database-mcp 0.6.4

A single-binary MCP server for MySQL, MariaDB, PostgreSQL, and SQLite
name: Release

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_TERM_COLOR: always

permissions:
  contents: write
  packages: write

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            artifact: database-mcp
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            artifact: database-mcp
          - target: x86_64-apple-darwin
            os: macos-latest
            artifact: database-mcp
          - target: aarch64-apple-darwin
            os: macos-latest
            artifact: database-mcp
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            artifact: database-mcp.exe
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Install cross-compilation tools (Linux ARM)
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

      - name: Build release binary
        run: cargo build --release --target ${{ matrix.target }}
        env:
          CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc

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

      - name: Package artifact (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Compress-Archive -Path target/${{ matrix.target }}/release/${{ matrix.artifact }} -DestinationPath database-mcp-${{ matrix.target }}.zip

      - uses: actions/upload-artifact@v7
        with:
          name: database-mcp-${{ matrix.target }}
          path: database-mcp-${{ matrix.target }}.*

  release:
    name: Create Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: cocogitto/cocogitto-action@v4
        id: changelog
        with:
          command: changelog
          args: --at ${{ github.ref_name }}
      - uses: actions/download-artifact@v8
        with:
          path: artifacts
          merge-multiple: true

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          body: ${{ steps.changelog.outputs.stdout }}
          files: |
            artifacts/*.tar.gz
            artifacts/*.zip

  ghcr-io:
    name: Publish to ghcr.io
    needs: [release]
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - uses: actions/checkout@v6

      - uses: docker/setup-buildx-action@v4

      - uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - id: meta
        uses: docker/metadata-action@v6
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=raw,value=latest
          labels: |
            io.modelcontextprotocol.server.name=ai.haymon/database
            org.opencontainers.image.title=database-mcp
            org.opencontainers.image.description=Database MCP server for MySQL, MariaDB, PostgreSQL & SQLite
            org.opencontainers.image.licenses=MIT

      - uses: docker/build-push-action@v7
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          sbom: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            VERSION=${{ github.ref_name }}

  registry-modelcontextprotocol-io:
    name: Publish to registry.modelcontextprotocol.io
    needs: [ghcr-io]
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - uses: actions/checkout@v6

      - name: Install mcp-publisher
        run: |
          curl -fsSL "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher

      - name: Authenticate to MCP Registry
        run: ./mcp-publisher login dns --domain=haymon.ai --private-key=${{ secrets.MCP_REGISTRY_PRIVATE_KEY }}

      - name: Validate server.json
        run: ./mcp-publisher validate

      - name: Publish to MCP Registry
        run: ./mcp-publisher publish

  crates-io:
    name: Publish to crates.io
    needs: [release]
    runs-on: ubuntu-latest
    continue-on-error: true
    permissions:
      id-token: write
      contents: read
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - uses: rust-lang/crates-io-auth-action@v1
        id: auth

      - name: Publish workspace
        run: cargo publish --workspace
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}