Skip to content

Commit e679027

Browse files
ci: verify schema is correct
1 parent 1faec78 commit e679027

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

.github/workflows/pre-release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Pre-release
2+
3+
permissions: read-all
4+
5+
on:
6+
push:
7+
branches:
8+
- release-please-*
9+
10+
jobs:
11+
pre-release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
16+
with:
17+
fetch-depth: 2
18+
19+
- name: Install MCP Publisher
20+
run: |
21+
export TAG=$(curl -sL https://api.github.com/repos/modelcontextprotocol/registry/releases/latest | jq -r ".tag_name")
22+
export VERSION="${TAG#v}"
23+
export OS=$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
24+
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/${TAG}/mcp-publisher_${VERSION}_${OS}.tar.gz" | tar xz mcp-publisher
25+
26+
- name: Verify server.json
27+
run: npm run verify-server-json-version

.github/workflows/publish-to-npm-on-tag.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ jobs:
8282

8383
- name: Install MCP Publisher
8484
run: |
85-
export VERSION="1.2.1"
85+
export TAG=$(curl -sL https://api.github.com/repos/modelcontextprotocol/registry/releases/latest | jq -r ".tag_name")
86+
export VERSION="${TAG#v}"
8687
export OS=$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
87-
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v${VERSION}/mcp-publisher_${VERSION}_${OS}.tar.gz" | tar xz mcp-publisher
88+
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/${TAG}/mcp-publisher_${VERSION}_${OS}.tar.gz" | tar xz mcp-publisher
8889
8990
- name: Login to MCP Registry
9091
run: ./mcp-publisher login github-oidc

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"test:only:no-build": "node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
2121
"test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"",
2222
"prepare": "node --experimental-strip-types scripts/prepare.ts",
23-
"sync-server-json-version": "node --experimental-strip-types scripts/sync-server-json-version.ts && npm run format"
23+
"sync-server-json-version": "node --experimental-strip-types scripts/sync-server-json-version.ts && npm run format",
24+
"verify-server-json-version": "node --experimental-strip-types scripts/verify-server-json-version.ts"
2425
},
2526
"files": [
2627
"build/src",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @license
9+
* Copyright 2025 Google LLC
10+
* SPDX-License-Identifier: Apache-2.0
11+
*/
12+
import {execSync} from 'node:child_process';
13+
import fs from 'node:fs';
14+
15+
const serverJsonFilePath = './server.json';
16+
const serverJson = JSON.parse(fs.readFileSync(serverJsonFilePath, 'utf-8'));
17+
fs.unlinkSync(serverJsonFilePath);
18+
19+
// Create the new server.json
20+
execSync('./mcp-publisher init');
21+
22+
const newServerJson = JSON.parse(fs.readFileSync(serverJsonFilePath, 'utf-8'));
23+
24+
const propertyToVerify = ['$schema'];
25+
const diffProps = [];
26+
27+
for (const prop of propertyToVerify) {
28+
if (serverJson[prop] !== newServerJson[prop]) {
29+
diffProps.push(prop);
30+
}
31+
}
32+
33+
fs.writeFileSync('./server.json', JSON.stringify(serverJson, null, 2));
34+
35+
if (diffProps.length) {
36+
throw new Error(
37+
`The following props did not match the latest init value:\n${diffProps.map(
38+
prop => `- "${prop}": "${newServerJson[prop]}"`,
39+
)}`,
40+
);
41+
}

0 commit comments

Comments
 (0)