From 36c185980f1a97befc4071c8728d4b0ab730f232 Mon Sep 17 00:00:00 2001 From: Divyanshu Jethi <67845323+divyanshujethi@users.noreply.github.com> Date: Sun, 6 Dec 2026 12:43:43 +0530 Subject: [PATCH] fix(ci): guard npm/PyPI publish and filter 404 PyPI refs in MCP Registry publish --- .github/workflows/publish-mcp.yml | 29 ++++++++++++++++++++++++++++- .github/workflows/publish-npm.yml | 12 +++++++++++- .github/workflows/publish-pypi.yml | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-mcp.yml b/.github/workflows/publish-mcp.yml index aeddb9f1..bcf99fea 100644 --- a/.github/workflows/publish-mcp.yml +++ b/.github/workflows/publish-mcp.yml @@ -72,8 +72,35 @@ jobs: tar -xzf "$archive" mcp-publisher + - name: Filter unpublished PyPI registry entries (if PyPI release not yet published) + run: | + set -euo pipefail + cp server.json server.json.bak + node -e ' + const fs = require("node:fs"); + const manifest = JSON.parse(fs.readFileSync("server.json", "utf8")); + (async () => { + const kept = []; + for (const pkg of manifest.packages || []) { + if (pkg.registryType === "pypi") { + const res = await fetch(`https://pypi.org/pypi/${pkg.identifier}/${pkg.version}/json`); + if (!res.ok) { + console.log(`::warning::PyPI package ${pkg.identifier}@${pkg.version} not found (${res.status}) — omitting from this MCP Registry publish.`); + continue; + } + } + kept.push(pkg); + } + manifest.packages = kept; + fs.writeFileSync("server.json", `${JSON.stringify(manifest, null, 2)}\n`, "utf8"); + })().catch((err) => { console.error(err); process.exit(1); }); + ' + - name: Authenticate with MCP Registry (GitHub OIDC) run: ./mcp-publisher login github-oidc - name: Publish server.json to MCP Registry - run: ./mcp-publisher publish + run: | + set -euo pipefail + trap 'if [ -f server.json.bak ]; then mv server.json.bak server.json; fi' EXIT + ./mcp-publisher publish diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 6e0caf6a..44b0f66c 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -68,4 +68,14 @@ jobs: - name: Publish package to npm with SLSA provenance env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm publish --provenance --access public + run: | + PKG_VER=$(node -e "console.log(JSON.parse(require('fs').readFileSync('package.json','utf8')).version)") + if npm view "@ritualdev-lab/mcpshelf@${PKG_VER}" version >/dev/null 2>&1; then + echo "Skipping @ritualdev-lab/mcpshelf@${PKG_VER} (already published on npm)" + exit 0 + fi + if [ -z "${NODE_AUTH_TOKEN:-}" ]; then + echo "::warning::secrets.NPM_TOKEN is not configured — skipping npmjs.org publish." + exit 0 + fi + npm publish --provenance --access public diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index c7fb1355..5aa5f161 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -55,7 +55,7 @@ jobs: publish-pypi: name: Publish mcpshelf to PyPI needs: [build-and-test] - if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/python-v') || startsWith(github.ref, 'refs/tags/v') + if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/python-v') runs-on: ubuntu-latest permissions: id-token: write