Skip to content

Commit acd4855

Browse files
authored
Fixing GitHub Actions for PyPI and MCP publish (#190)
* Remove on-success and on-failure from publish_mcp.yml * Updated schema * Added check on tag/version before Publish * Fixed Publish to MCP Registry
1 parent 44651a5 commit acd4855

File tree

4 files changed

+58
-54
lines changed

4 files changed

+58
-54
lines changed

.github/workflows/publish.yml

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Publish (PyPI + MCP Registry)
22

33
on:
44
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v*'
58

69
concurrency:
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

.github/workflows/publish_mcp.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,36 @@ name: Publish MCP Registry
22

33
on:
44
workflow_dispatch:
5-
workflow_run:
6-
workflows: ["Publish PyPI"]
7-
types: [completed]
85

96
concurrency:
10-
group: publish-${{ github.ref }}
7+
group: publish-mcp-${{ github.ref }}
118
cancel-in-progress: true
129

1310
jobs:
14-
on-success:
11+
mcp-registry:
1512
name: Publish to MCP Registry
1613
runs-on: ubuntu-latest
17-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
timeout-minutes: 10
1815
permissions:
1916
contents: read
20-
id-token: write
17+
id-token: write # REQUIRED for MCP Registry GitHub OIDC login
2118
steps:
2219
- name: Checkout
2320
uses: actions/checkout@v4
2421

2522
- name: Install MCP Publisher
2623
run: |
27-
set -e
24+
set -euo pipefail
2825
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
2926
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
27+
echo "Get the latest release version"
3028
LATEST_VERSION=$(curl -s https://api.github.com/repos/modelcontextprotocol/registry/releases/latest | jq -r '.tag_name')
31-
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/${LATEST_VERSION}/mcp-publisher_${LATEST_VERSION#v}_${OS}_${ARCH}.tar.gz" | tar xz mcp-publisher
29+
echo "Installing MCP Publisher version: $LATEST_VERSION"
30+
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_${OS}_${ARCH}.tar.gz" \
31+
| tar xz mcp-publisher
3232
3333
- name: Login to MCP Registry
3434
run: ./mcp-publisher login github-oidc
3535

3636
- name: Publish to MCP Registry
37-
run: |
38-
echo "PyPI workflow succeeded - Publishing to MCP Registry"
39-
./mcp-publisher publish
40-
41-
on-failure:
42-
name: Handle PyPI Failure
43-
runs-on: ubuntu-latest
44-
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
45-
steps:
46-
- name: Log PyPI Failure
47-
run: echo "PyPI workflow failed - MCP Registry publication skipped"
37+
run: ./mcp-publisher publish

.github/workflows/publish_pypi.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ name: Publish PyPI
22

33
on:
44
workflow_dispatch:
5-
push:
6-
tags:
7-
- "v*"
85

96
concurrency:
107
group: publish-pypi-${{ github.ref }}
@@ -14,47 +11,43 @@ jobs:
1411
pypi:
1512
name: Publish PyPI
1613
runs-on: ubuntu-latest
14+
timeout-minutes: 15
1715
permissions:
1816
contents: read
19-
id-token: write # REQUIRED for PyPI Trusted Publishing (OIDC)
17+
id-token: write
2018
steps:
2119
- name: Checkout
2220
uses: actions/checkout@v4
2321

2422
- name: Set up Python
2523
uses: actions/setup-python@v5
2624
with:
27-
python-version: "3.12"
25+
python-version: "3.10"
2826

2927
- name: Install uv
3028
run: pipx install uv
3129

32-
# --- Optional checks (keep for now; can be moved to PR CI later) ---
33-
- name: Sync deps
30+
- name: Sync dependencies
3431
run: uv sync
3532

36-
- name: Ruff lint
33+
- name: Run ruff lint
3734
run: uvx ruff check .
3835

39-
- name: Ruff format check
36+
- name: Run ruff format check
4037
run: uvx ruff format --check .
4138

42-
- name: Run tests (if present)
39+
- name: Run tests
4340
run: |
4441
if [ -d tests ]; then
4542
uv run pytest -q
4643
else
4744
echo "No tests/ directory; skipping."
4845
fi
4946
50-
# --- Build artifacts for PyPI ---
51-
- name: Build sdist & wheel
47+
- name: Build package
5248
run: uv build
5349

54-
# --- Publish using Trusted Publishing (no tokens) ---
5550
- name: Publish to PyPI
5651
uses: pypa/gh-action-pypi-publish@release/v1
5752
with:
58-
packages-dir: dist
59-
# For a dress rehearsal, you can set:
60-
# repository-url: https://test.pypi.org/legacy/
53+
packages-dir: dist

server.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
2+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
33
"name": "io.github.robotmcp/ros-mcp-server",
44
"description": "Connect AI models like Claude & ChatGPT with ROS robots using MCP",
55
"repository": {

0 commit comments

Comments
 (0)