-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (140 loc) · 5.33 KB
/
Copy pathpublish.yml
File metadata and controls
161 lines (140 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Publish to PyPI and MCP Registry
on:
push:
tags:
- "*-mcp-v*"
permissions:
contents: read
jobs:
parse-tag:
runs-on: ubuntu-latest
outputs:
server: ${{ steps.parse.outputs.server }}
version: ${{ steps.parse.outputs.version }}
steps:
- name: Parse tag
id: parse
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Extract server name (everything before -v) and version (after -v)
SERVER="${TAG%-v*}"
VERSION="${TAG##*-v}"
echo "server=${SERVER}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Parsed tag: server=${SERVER}, version=${VERSION}"
- uses: actions/checkout@v6
- name: Verify version matches tag
working-directory: servers/${{ steps.parse.outputs.server }}
run: |
TOML_VERSION=$(python3 -c "
import re
with open('pyproject.toml') as f:
match = re.search(r'^version\s*=\s*\"(.+?)\"', f.read(), re.MULTILINE)
print(match.group(1))
")
TAG_VERSION="${{ steps.parse.outputs.version }}"
if [[ "${TOML_VERSION}" != "${TAG_VERSION}" ]]; then
echo "::error::Version mismatch: pyproject.toml has ${TOML_VERSION}, tag has ${TAG_VERSION}"
exit 1
fi
echo "Version verified: ${TOML_VERSION}"
test:
needs: parse-tag
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "servers/${{ needs.parse-tag.outputs.server }}/uv.lock"
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
working-directory: servers/${{ needs.parse-tag.outputs.server }}
run: uv sync --group dev
- name: Run unit tests
working-directory: servers/${{ needs.parse-tag.outputs.server }}
run: uv run pytest tests/ --ignore=tests/test_live.py -v --tb=short
publish:
needs: [parse-tag, test]
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Build package
working-directory: servers/${{ needs.parse-tag.outputs.server }}
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: servers/${{ needs.parse-tag.outputs.server }}/dist/
mcp-registry:
needs: [parse-tag, publish]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6
- name: Check for server.json
id: check
working-directory: servers/${{ needs.parse-tag.outputs.server }}
run: |
if [ -f server.json ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Install mcp-publisher
if: steps.check.outputs.exists == 'true'
env:
MCP_PUBLISHER_VERSION: "1.8.0"
run: |
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')"
ASSET="mcp-publisher_${OS}_${ARCH}.tar.gz"
# Pinned sha256 checksums from the v1.8.0 release's
# registry_1.8.0_checksums.txt (covers both mcp-publisher_* and
# registry_* assets despite the "registry_" filename prefix).
# Only linux runners are expected here (job runs on ubuntu-latest).
case "${ASSET}" in
mcp-publisher_linux_amd64.tar.gz)
SHA256="1370446bbe74d562608e8005a6ccce02d146a661fbd78674e11cc70b9618d6cf"
;;
mcp-publisher_linux_arm64.tar.gz)
SHA256="c978982c60e1b4903a976de090f04dc4fac4a320daa50704fcad2dbc93433d62"
;;
*)
echo "::error::No pinned checksum recorded for ${ASSET}; refusing to install mcp-publisher unverified"
exit 1
;;
esac
curl -L -o mcp-publisher.tar.gz \
"https://github.com/modelcontextprotocol/registry/releases/download/v${MCP_PUBLISHER_VERSION}/${ASSET}"
echo "${SHA256} mcp-publisher.tar.gz" | sha256sum -c -
tar xz -f mcp-publisher.tar.gz mcp-publisher
- name: Update version in server.json
if: steps.check.outputs.exists == 'true'
working-directory: servers/${{ needs.parse-tag.outputs.server }}
run: |
VERSION="${{ needs.parse-tag.outputs.version }}"
jq --arg v "$VERSION" '(.version = $v) | (.packages[].version = $v)' server.json > server.tmp && mv server.tmp server.json
- name: Authenticate to MCP Registry
if: steps.check.outputs.exists == 'true'
run: ./mcp-publisher login github-oidc
- name: Publish to MCP Registry
if: steps.check.outputs.exists == 'true'
working-directory: servers/${{ needs.parse-tag.outputs.server }}
run: $GITHUB_WORKSPACE/mcp-publisher publish