From 27a3a58af5696ecdc819fdf99e871e6af83aca3b Mon Sep 17 00:00:00 2001 From: Savio Dias Date: Tue, 13 Oct 2026 18:25:56 +0530 Subject: [PATCH] fix(ci): bump both server.json version fields in the Bump Version workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The server.json update step replaced the first `"version": ""` string it found. Since the 2.x line, server.json carries the version in two places — the top-level `version` and the nested `packages[].version` — and the top-level one comes first, so the nested field was never updated. The verify step reads `packages[0].version`, so every dispatch failed with: package.json=X lock=X lock.root=X server.json= Version mismatch: expected X, got Parse server.json and assign both fields explicitly instead of string-replacing, and extend the verify step to cover the top-level field so a partial update cannot pass silently. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/bump-version.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index aa3ba73f..52b7d66e 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -73,24 +73,25 @@ jobs: - name: "Update server.json package version" env: - OLD_VERSION: ${{ steps.bump.outputs.old_version }} NEW_VERSION: ${{ steps.bump.outputs.new_version }} run: | set -e node -e ' const fs = require("fs"); - const oldV = process.env.OLD_VERSION; const newV = process.env.NEW_VERSION; - let s = fs.readFileSync("server.json", "utf8"); - // Only the nested packages[].version matches ""; - // the top-level "version" is the schema version (1.0.0) and is left alone. - const needle = `"version": "${oldV}"`; - if (!s.includes(needle)) { - console.error(`Could not find ${needle} in server.json`); + const srv = JSON.parse(fs.readFileSync("server.json", "utf8")); + if (!Array.isArray(srv.packages) || srv.packages.length === 0) { + console.error("server.json has no packages[] entry to update"); process.exit(1); } - s = s.replace(needle, `"version": "${newV}"`); - fs.writeFileSync("server.json", s); + // Both the top-level "version" and the nested packages[].version track + // the published package version (since the 2.x line). Set each field + // explicitly rather than string-replacing: a textual replace updates only + // the first match, which left packages[0].version stale and failed the + // verify step below. + srv.version = newV; + srv.packages[0].version = newV; + fs.writeFileSync("server.json", JSON.stringify(srv, null, 2) + "\n"); ' - name: "Verify all three files are in sync" @@ -102,8 +103,9 @@ jobs: LOCK_TOP=$(node -p 'require("./package-lock.json").version') LOCK_ROOT=$(node -p 'require("./package-lock.json").packages[""].version') SRV=$(node -p 'require("./server.json").packages[0].version') - echo "package.json=$PKG lock=$LOCK_TOP lock.root=$LOCK_ROOT server.json=$SRV" - for v in "$PKG" "$LOCK_TOP" "$LOCK_ROOT" "$SRV"; do + SRV_TOP=$(node -p 'require("./server.json").version') + echo "package.json=$PKG lock=$LOCK_TOP lock.root=$LOCK_ROOT server.json=$SRV server.json.top=$SRV_TOP" + for v in "$PKG" "$LOCK_TOP" "$LOCK_ROOT" "$SRV" "$SRV_TOP"; do if [ "$v" != "$NEW" ]; then echo "Version mismatch: expected $NEW, got $v" exit 1