|
| 1 | +name: Publish (PyPI + MCP Registry) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: publish-${{ github.ref }} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + pypi: |
| 12 | + name: Publish to PyPI |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + id-token: write # REQUIRED for PyPI Trusted Publishing (OIDC) |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: "3.12" |
| 25 | + |
| 26 | + - name: Install uv |
| 27 | + run: pipx install uv |
| 28 | + |
| 29 | + # --- Optional checks (keep for now; can be moved to PR CI later) --- |
| 30 | + - name: Sync deps |
| 31 | + run: uv sync |
| 32 | + |
| 33 | + - name: Ruff lint |
| 34 | + run: uvx ruff check . |
| 35 | + |
| 36 | + - name: Ruff format check |
| 37 | + run: uvx ruff format --check . |
| 38 | + |
| 39 | + - name: Run tests (if present) |
| 40 | + run: | |
| 41 | + if [ -d tests ]; then |
| 42 | + uv run pytest -q |
| 43 | + else |
| 44 | + echo "No tests/ directory; skipping." |
| 45 | + fi |
| 46 | +
|
| 47 | + # --- Build artifacts for PyPI --- |
| 48 | + - name: Build sdist & wheel |
| 49 | + run: uv build |
| 50 | + |
| 51 | + # --- Publish using Trusted Publishing (no tokens) --- |
| 52 | + - name: Publish to PyPI |
| 53 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 54 | + with: |
| 55 | + packages-dir: dist |
| 56 | + # For a dress rehearsal, you can set: |
| 57 | + # repository-url: https://test.pypi.org/legacy/ |
| 58 | + |
| 59 | + registry: |
| 60 | + name: Publish to MCP Registry |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: pypi |
| 63 | + permissions: |
| 64 | + contents: read |
| 65 | + id-token: write # REQUIRED for MCP Registry GitHub OIDC login |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + |
| 70 | + # Small delay to allow PyPI metadata to propagate |
| 71 | + - name: Wait briefly |
| 72 | + run: sleep 20 |
| 73 | + |
| 74 | + - name: Install MCP Publisher |
| 75 | + run: | |
| 76 | + set -e |
| 77 | + OS=$(uname -s | tr '[:upper:]' '[:lower:]') |
| 78 | + ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') |
| 79 | + echo "Get the latest release version" |
| 80 | + LATEST_VERSION=$(curl -s https://api.github.com/repos/modelcontextprotocol/registry/releases/latest | jq -r '.tag_name') |
| 81 | + 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" \ |
| 83 | + | tar xz mcp-publisher |
| 84 | +
|
| 85 | + - name: Login to MCP Registry (OIDC) |
| 86 | + run: ./mcp-publisher login github-oidc |
| 87 | + |
| 88 | + - name: Publish server.json to MCP Registry |
| 89 | + run: ./mcp-publisher publish |
0 commit comments