Explorar o código

build: 0.10.1, and make a version drift fail the build

I published 0.10.0 with api/openapi.json still saying 0.9.2. That file
ships in the server package and is served at /openapi.json, so the live
documentation would have misreported the version of the running server.

Correcting it needs a new version rather than a rebuild, because a
published version number is never reused for different content. So
0.10.0 exists, is published, and must never be deployed; 0.10.1 is the
one to ship.

The underlying failure is that keeping the two in sync was a line in a
checklist I did not follow. scripts/check-version-sync.sh is that line
turned into a check, wired in at build.sh's top level so it covers the
local, Docker and publish paths alike - the first placement I tried only
covered --local, which is not the path a release takes.

Verified by drifting VERSION on purpose: the release aborts before
anything is built.

Also ran the route sweep the release procedure calls for, properly this
time - an earlier regex matched one route out of 72 and would have
reported a clean sweep whatever was missing. 72 registered routes, no
undocumented /api route.
fszontagh hai 1 mes
pai
achega
4407b4970a
Modificáronse 5 ficheiros con 32 adicións e 2 borrados
  1. 2 0
      CLAUDE.md
  2. 1 1
      VERSION
  3. 1 1
      api/openapi.json
  4. 8 0
      packaging/build.sh
  5. 20 0
      scripts/check-version-sync.sh

+ 2 - 0
CLAUDE.md

@@ -146,6 +146,8 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 
 ## Deploy / publish
 
+**`VERSION` and `api/openapi.json`'s `info.version` must agree, and `packaging/build.sh` now refuses to build unless they do** (`scripts/check-version-sync.sh`, run at the top level so it covers the local, Docker and publish paths alike). They drifted once: 0.10.0 was published with the docs claiming 0.9.2, and since `openapi.json` ships in the server package and is served at `/openapi.json`, the stale value was live. **Correcting it cost a whole release**, because a published version number is never reused for different content - which is why 0.10.0 exists but must never be deployed. A release step that relies on remembering is a release step that gets skipped, so it is a check rather than a checklist line.
+
 ```bash
 ./packaging/build.sh                                # Debian-13 .debs → dist/debian13/ (3 packages: server, webui, runner)
 ./packaging/build.sh --no-runner                    # skip the runner package

+ 1 - 1
VERSION

@@ -1 +1 @@
-0.10.0
+0.10.1

+ 1 - 1
api/openapi.json

@@ -2,7 +2,7 @@
   "openapi": "3.1.0",
   "info": {
     "title": "smartbotic-vectorapi",
-    "version": "0.9.2",
+    "version": "0.10.1",
     "description": "General-purpose REST API fronting smartbotic-database. Supports multi-project namespacing and multi-key authorization with per-project grants."
   },
   "components": {

+ 8 - 0
packaging/build.sh

@@ -31,6 +31,14 @@ DEB_REPO_DIR="${DEB_REPO_DIR:-/data/dev/smartbotics/smartbotics-deb-repo}"
 DIST_BASE="${PROJECT_DIR}/dist"
 
 VERSION="$(cat "$PROJECT_DIR/VERSION")"
+# VERSION and api/openapi.json's info.version must agree, checked HERE so it
+# covers every path - local, Docker and publish alike. They drifted once and
+# 0.10.0 was published with the docs claiming 0.9.2; openapi.json ships in the
+# server package and is served at /openapi.json, so a stale value is live, and
+# because a published version is never reused for different content, correcting
+# it cost a whole release. A release step that relies on remembering is a
+# release step that gets skipped.
+"$PROJECT_DIR/scripts/check-version-sync.sh"
 GIT_COMMIT="$(git -C "$PROJECT_DIR" rev-parse --short HEAD 2>/dev/null || echo "unknown")"
 
 # ---------------------------------------------------------------------------

+ 20 - 0
scripts/check-version-sync.sh

@@ -0,0 +1,20 @@
+#!/bin/sh
+# VERSION and openapi.json's info.version must agree.
+#
+# They drifted once and 0.10.0 was published with the docs claiming 0.9.2.
+# openapi.json SHIPS IN THE SERVER PACKAGE and is served at /openapi.json, so a
+# stale value is live and misleading - and because a published version number is
+# never reused for different content, correcting it costs a whole release.
+#
+# A release step that depends on remembering is a release step that gets
+# skipped, so this is a check rather than a line in a checklist.
+set -eu
+cd "$(dirname "$0")/.."
+file_version="$(tr -d ' \t\n' < VERSION)"
+api_version="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' api/openapi.json | head -1)"
+if [ "$file_version" != "$api_version" ]; then
+    echo "VERSION is '$file_version' but api/openapi.json info.version is '$api_version'" >&2
+    echo "Update api/openapi.json before releasing." >&2
+    exit 1
+fi
+echo "version sync OK ($file_version)"