|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Publish to MCP Registry |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + tags: ["v*"] # Triggers on version tags like v1.0.0 |
| 20 | + # allow manual triggering with no inputs required |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +jobs: |
| 24 | + publish: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + id-token: write # Required for OIDC authentication |
| 28 | + contents: read |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v5 |
| 33 | + |
| 34 | + - name: Wait for image in Artifact Registry |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + MAX_ATTEMPTS=3 |
| 38 | + VERSION=$(jq -r '.version' server.json) |
| 39 | + REGISTRY_URL="https://us-central1-docker.pkg.dev/v2/database-toolbox/toolbox/toolbox/manifests/${VERSION}" |
| 40 | +
|
| 41 | + # initially sleep time to wait for the version release |
| 42 | + sleep 10m |
| 43 | +
|
| 44 | + for i in $(seq 1 ${MAX_ATTEMPTS}); do |
| 45 | + echo "Attempt $i: Checking for image ${REGISTRY_URL}..." |
| 46 | + # Use curl to check the manifest header |
| 47 | + # Using -I to fetch headers only, -s silent, -f fail fast on errors. |
| 48 | + curl -Isf "${REGISTRY_URL}" > /dev/null |
| 49 | +
|
| 50 | + if [ $? -eq 0 ]; then |
| 51 | + echo "✅ Image found! Continuing to next steps." |
| 52 | + exit 0 |
| 53 | + else |
| 54 | + echo "❌ Image not found (likely 404 error) on attempt $i." |
| 55 | + if [ $i -lt ${MAX_ATTEMPTS} ]; then |
| 56 | + echo "Sleeping for 5 minutes before next attempt..." |
| 57 | + sleep 5m |
| 58 | + else |
| 59 | + echo "Maximum attempts reached. Image not found." |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | + fi |
| 63 | + done |
| 64 | +
|
| 65 | + - name: Install MCP Publisher |
| 66 | + run: | |
| 67 | + curl -L "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 |
| 68 | +
|
| 69 | + - name: Login to MCP Registry |
| 70 | + run: ./mcp-publisher login github-oidc |
| 71 | + |
| 72 | + - name: Publish to MCP Registry |
| 73 | + run: ./mcp-publisher publish --file=.registry/server.json |
0 commit comments