perf(tools): reduce schema token cost and response payload sizes #900
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*.*.*" | |
| pull_request: | |
| branches: | |
| - main | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_tag: ${{ steps.check.outputs.is_tag }} | |
| version: ${{ steps.tag.outputs.version }} | |
| is_stable: ${{ steps.tag.outputs.is_stable }} | |
| platforms: ${{ steps.platforms.outputs.platforms }} | |
| steps: | |
| - name: Check if tag push | |
| id: check | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| echo "is_tag=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_tag=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Process tag name | |
| id: tag | |
| if: steps.check.outputs.is_tag == 'true' | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Check if this is a stable release (no rc, alpha, beta, etc.) | |
| if [[ ! "$VERSION" =~ (rc|alpha|beta|pre|dev) ]]; then | |
| echo "is_stable=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_stable=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Determine platforms | |
| id: platforms | |
| run: | | |
| # Only build multi-arch on pushes/tags/releases, not on PRs | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| echo "platforms=linux/amd64" >> $GITHUB_OUTPUT | |
| else | |
| echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT | |
| fi | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: prepare | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 | |
| - name: Build and Push to Docker Hub | |
| uses: grafana/shared-workflows/actions/build-push-to-dockerhub@e7a3275d4c4978a3514801ec55708f1c599a6906 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| repository: grafana/mcp-grafana | |
| platforms: ${{ needs.prepare.outputs.platforms }} | |
| tags: | | |
| ${{ needs.prepare.outputs.is_tag == 'true' && needs.prepare.outputs.is_stable == 'true' && 'latest' || '' }} | |
| ${{ needs.prepare.outputs.is_tag == 'true' && needs.prepare.outputs.version || '' }} | |
| push: ${{ needs.prepare.outputs.is_tag == 'true' }} | |
| docker-alpine: | |
| runs-on: ubuntu-latest | |
| needs: prepare | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 | |
| - name: Build and Push Alpine to Docker Hub | |
| uses: grafana/shared-workflows/actions/build-push-to-dockerhub@e7a3275d4c4978a3514801ec55708f1c599a6906 | |
| with: | |
| context: . | |
| file: ./Dockerfile.alpine | |
| repository: grafana/mcp-grafana | |
| platforms: ${{ needs.prepare.outputs.platforms }} | |
| tags: | | |
| ${{ needs.prepare.outputs.is_tag == 'true' && needs.prepare.outputs.is_stable == 'true' && 'alpine' || '' }} | |
| ${{ needs.prepare.outputs.is_tag == 'true' && format('{0}-alpine', needs.prepare.outputs.version) || '' }} | |
| push: ${{ needs.prepare.outputs.is_tag == 'true' }} | |
| mcp-registry: | |
| runs-on: ubuntu-latest | |
| needs: docker | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| # Get the tag from the triggering workflow | |
| TAG=$(git describe --tags --exact-match HEAD 2>/dev/null || echo "") | |
| if [ -z "$TAG" ]; then | |
| echo "No tag found at HEAD" | |
| exit 1 | |
| fi | |
| echo "VERSION=$TAG" >> $GITHUB_OUTPUT | |
| - name: Extract image tag from version | |
| id: image-tag | |
| run: | | |
| # Extract the image tag from the version | |
| VERSION="${{ steps.version.outputs.VERSION }}" | |
| echo "IMAGE_TAG=${VERSION#v}" >> $GITHUB_OUTPUT | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y jq | |
| curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_linux_amd64.tar.gz" | tar xz mcp-publisher | |
| chmod +x mcp-publisher | |
| sudo mv mcp-publisher /usr/local/bin/ | |
| - name: Update server.json with Docker image | |
| run: | | |
| # Update the server.json with the correct Docker image reference | |
| # (note the image tag does not include the "v" prefix) | |
| jq --arg version "${{ steps.version.outputs.VERSION }}" \ | |
| --arg image "docker.io/grafana/mcp-grafana:${{ steps.image-tag.outputs.IMAGE_TAG }}" \ | |
| '.version = $version | .packages[0].identifier = $image' server.json > server.json.tmp | |
| mv server.json.tmp server.json | |
| - name: Login to MCP Registry | |
| run: mcp-publisher login github-oidc | |
| - name: Publish to MCP Registry | |
| run: mcp-publisher publish |