@@ -2,6 +2,9 @@ name: Publish (PyPI + MCP Registry)
22
33on :
44 workflow_dispatch :
5+ push :
6+ tags :
7+ - ' v*'
58
69concurrency :
710 group : publish-${{ github.ref }}
@@ -11,54 +14,73 @@ jobs:
1114 pypi :
1215 name : Publish to PyPI
1316 runs-on : ubuntu-latest
17+ timeout-minutes : 15
1418 permissions :
1519 contents : read
1620 id-token : write # REQUIRED for PyPI Trusted Publishing (OIDC)
1721 steps :
1822 - name : Checkout
1923 uses : actions/checkout@v4
2024
25+ - name : Validate version matches tag
26+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
27+ run : |
28+ set -euo pipefail
29+
30+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
31+ PYPROJECT_VERSION=$(grep -oP '^version = "\K[^"]+' pyproject.toml)
32+ SERVER_VERSION=$(grep -oP '"version":\s*"\K[^"]+' server.json | head -1)
33+ SERVER_PKG_VERSION=$(grep -oP '"version":\s*"\K[^"]+' server.json | tail -1)
34+
35+ ERRORS=0
36+ [ "$PYPROJECT_VERSION" != "$TAG_VERSION" ] && echo "pyproject.toml: $PYPROJECT_VERSION != $TAG_VERSION" && ERRORS=1
37+ [ "$SERVER_VERSION" != "$TAG_VERSION" ] && echo "server.json: $SERVER_VERSION != $TAG_VERSION" && ERRORS=1
38+ [ "$SERVER_PKG_VERSION" != "$TAG_VERSION" ] && echo "server.json package: $SERVER_PKG_VERSION != $TAG_VERSION" && ERRORS=1
39+
40+ if [ $ERRORS -eq 1 ]; then
41+ echo "Please update all version fields to $TAG_VERSION before creating the tag."
42+ exit 1
43+ fi
44+
45+ echo "All versions match: $TAG_VERSION"
46+
2147 - name : Set up Python
2248 uses : actions/setup-python@v5
2349 with :
24- python-version : " 3.12 "
50+ python-version : " 3.10 "
2551
2652 - name : Install uv
2753 run : pipx install uv
2854
29- # --- Optional checks (keep for now; can be moved to PR CI later) ---
30- - name : Sync deps
55+ - name : Sync dependencies
3156 run : uv sync
3257
33- - name : Ruff lint
58+ - name : Run ruff lint
3459 run : uvx ruff check .
3560
36- - name : Ruff format check
61+ - name : Run ruff format check
3762 run : uvx ruff format --check .
3863
39- - name : Run tests (if present)
64+ - name : Run tests
4065 run : |
4166 if [ -d tests ]; then
4267 uv run pytest -q
4368 else
4469 echo "No tests/ directory; skipping."
4570 fi
4671
47- # --- Build artifacts for PyPI ---
48- - name : Build sdist & wheel
72+ - name : Build package
4973 run : uv build
5074
51- # --- Publish using Trusted Publishing (no tokens) ---
5275 - name : Publish to PyPI
5376 uses : pypa/gh-action-pypi-publish@release/v1
5477 with :
5578 packages-dir : dist
56- # For a dress rehearsal, you can set:
57- # repository-url: https://test.pypi.org/legacy/
5879
5980 registry :
6081 name : Publish to MCP Registry
6182 runs-on : ubuntu-latest
83+ timeout-minutes : 10
6284 needs : pypi
6385 permissions :
6486 contents : read
@@ -67,23 +89,22 @@ jobs:
6789 - name : Checkout
6890 uses : actions/checkout@v4
6991
70- # Small delay to allow PyPI metadata to propagate
71- - name : Wait briefly
92+ - name : Wait for PyPI metadata propagation
7293 run : sleep 20
7394
7495 - name : Install MCP Publisher
7596 run : |
76- set -e
97+ set -euo pipefail
7798 OS=$(uname -s | tr '[:upper:]' '[:lower:]')
7899 ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
79100 echo "Get the latest release version"
80101 LATEST_VERSION=$(curl -s https://api.github.com/repos/modelcontextprotocol/registry/releases/latest | jq -r '.tag_name')
81102 echo "Installing MCP Publisher version: $LATEST_VERSION"
82- curl -L "https://github.com/modelcontextprotocol/registry/releases/download/${LATEST_VERSION}/ mcp-publisher_${LATEST_VERSION#v}_ ${OS}_${ARCH}.tar.gz" \
103+ curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/ download/mcp-publisher_${OS}_${ARCH}.tar.gz" \
83104 | tar xz mcp-publisher
84105
85- - name : Login to MCP Registry (OIDC)
106+ - name : Login to MCP Registry
86107 run : ./mcp-publisher login github-oidc
87108
88- - name : Publish server.json to MCP Registry
109+ - name : Publish to MCP Registry
89110 run : ./mcp-publisher publish
0 commit comments