5353echo " ✓ package tests pass"
5454
5555# Step 3: Verify version consistency
56+ #
57+ # server.json carries the release version twice: once at the top level, and once
58+ # inside the npm entry of `packages`, which is the field the MCP Registry
59+ # resolves the tarball from. Nothing synchronises the three numbers - they are
60+ # hand-edited - so all of them are compared, not just the top-level one. A
61+ # release that bumped package.json and server.json but missed the nested version
62+ # would register a new server entry pointing at the previous tarball, and the
63+ # Registry would accept it because that older tarball exists and carries the
64+ # right mcpName.
5665PKG_VERSION=$( node -e " console.log(require('$PKG_DIR /package.json').version)" )
5766SERVER_VERSION=$( node -e " console.log(require('$PKG_DIR /server.json').version)" )
67+ SERVER_NPM_VERSION=$( node -e "
68+ const npm = (require('$PKG_DIR /server.json').packages || [])
69+ .find((p) => p.registryType === 'npm');
70+ console.log(npm ? npm.version : '<no npm package entry>');
71+ " )
5872echo " "
59- echo " package.json version: $PKG_VERSION "
60- echo " server.json version: $SERVER_VERSION "
73+ echo " package.json version: $PKG_VERSION "
74+ echo " server.json version: $SERVER_VERSION "
75+ echo " server.json npm package: $SERVER_NPM_VERSION "
6176
6277# A mismatch here is fatal rather than a warning. The two files are published to
6378# two different registries under one version, and a warning scrolls past in the
@@ -67,19 +82,61 @@ if [ "$PKG_VERSION" != "$SERVER_VERSION" ]; then
6782 echo " ERROR: version mismatch between package.json ($PKG_VERSION ) and server.json ($SERVER_VERSION )" >&2
6883 exit 1
6984fi
85+ if [ " $PKG_VERSION " != " $SERVER_NPM_VERSION " ]; then
86+ echo " ERROR: version mismatch between package.json ($PKG_VERSION ) and the npm entry in server.json ($SERVER_NPM_VERSION )" >&2
87+ echo " The MCP Registry resolves the tarball from packages[].version, so this would" >&2
88+ echo " publish a $PKG_VERSION server entry pointing at the $SERVER_NPM_VERSION tarball." >&2
89+ exit 1
90+ fi
7091
7192# The npm package contains no engine; every install fetches one from the release
72- # tagged with this version. Publishing before those assets exist produces a
73- # package that installs cleanly and then has nothing to run.
93+ # tagged with the engine version pinned in bin/fetch-engine.js, which is
94+ # deliberately not this package's version (see the ENGINE_VERSION comment there:
95+ # a client-only patch release must not start asking for a tag nobody published).
96+ # Publishing before those assets exist produces a package that installs cleanly
97+ # and then has nothing to run.
98+ #
99+ # Every asset is probed, not just one. publish-release-assets.sh uploads the
100+ # whole staging directory in a single `gh release upload`, so a network drop or
101+ # a rate limit part-way through leaves the release with some platforms attached
102+ # and others missing - and a one-platform probe would wave that through, giving
103+ # users on the missing platforms exactly the empty install this gate exists to
104+ # prevent. The list mirrors BINARIES + WINDOWS_SIDECAR there, which is the same
105+ # set bin/fetch-engine.js resolves against.
74106ENGINE_VERSION=$( node -e " console.log(require('$PKG_DIR /bin/fetch-engine').ENGINE_VERSION)" )
75- echo " engine version: $ENGINE_VERSION (fetched at install time)"
76- if ! curl -fsSL -o /dev/null \
77- " https://github.com/codegraph-ai/CodeGraph/releases/download/v${ENGINE_VERSION} /codegraph-server-linux-x64.sha256" ; then
78- echo " ERROR: no published engine assets for v${ENGINE_VERSION} " >&2
79- echo " Run ./scripts/publish-release-assets.sh first, or installs will find no engine." >&2
107+ ENGINE_ASSETS=(
108+ " codegraph-server-darwin-arm64"
109+ " codegraph-server-darwin-x64"
110+ " codegraph-server-linux-x64"
111+ " codegraph-server-win32-x64.exe"
112+ " onnxruntime.dll"
113+ )
114+ RELEASE_BASE=" https://github.com/codegraph-ai/CodeGraph/releases/download/v${ENGINE_VERSION} "
115+
116+ echo " "
117+ echo " engine version: $ENGINE_VERSION (fetched at install time)"
118+ echo " Checking published engine assets for v${ENGINE_VERSION} ..."
119+ missing_assets=0
120+ for asset in " ${ENGINE_ASSETS[@]} " ; do
121+ # A binary and its checksum are separate assets and the client needs both, so
122+ # both are probed. The binaries are requested one byte at a time - presence is
123+ # the question here, and downloading ~120 MB to answer it is not worth it.
124+ if ! curl -fsSL -o /dev/null -r 0-0 " $RELEASE_BASE /$asset " \
125+ || ! curl -fsSL -o /dev/null " $RELEASE_BASE /$asset .sha256" ; then
126+ printf ' ✗ %s\n' " $asset "
127+ missing_assets=1
128+ else
129+ printf ' ✓ %s\n' " $asset "
130+ fi
131+ done
132+
133+ if [ " $missing_assets " -ne 0 ]; then
134+ echo " ERROR: the release v${ENGINE_VERSION} is missing engine assets (binary or .sha256)." >&2
135+ echo " Run ./scripts/publish-release-assets.sh --publish first, or installs on those" >&2
136+ echo " platforms will find no engine." >&2
80137 exit 1
81138fi
82- echo " ✓ engine assets are published for v${ENGINE_VERSION} "
139+ echo " ✓ every engine asset is published for v${ENGINE_VERSION} "
83140
84141# Step 4: Pack
85142echo " "
0 commit comments