Skip to content

Commit be1b03a

Browse files
committed
fix(release): wire rest.rst example versions into bump/verify; fail on unparseable version
The gateway-version literals in docs/api/rest.rst example responses (root `/` and version-info `vendor_info`) were bumped by hand and were not covered by `release.sh bump`/`verify`, so a future release would leave them stale and `verify` would not catch it. Bump and verify them now, anchored on the adjacent `name` keys so the SOVD API `"version": "1.0.0"` is never rewritten or checked. Also harden the no-arg `verify` consistency path: a version pattern that fails to match falls through as `unknown`, and an all-`unknown` run would collapse to a single unique value and false-pass. Treat any `unknown` as a hard failure.
1 parent a5a3964 commit be1b03a

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

scripts/release.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ CONF_PY="${REPO_ROOT}/docs/conf.py"
3535
DOCS_PYPROJECT="${REPO_ROOT}/docs/pyproject.toml"
3636
DOXYFILE="${REPO_ROOT}/docs/Doxyfile"
3737
QUALITY_DECL="${REPO_ROOT}/QUALITY_DECLARATION.md"
38+
REST_RST="${REPO_ROOT}/docs/api/rest.rst"
3839

3940
usage() {
4041
echo "Usage: $0 {bump <version>|verify [<version>]}"
@@ -126,6 +127,20 @@ cmd_bump() {
126127
echo " QUALITY_DECLARATION.md: -> ${target_version}"
127128
fi
128129

130+
# Update the gateway-version literals in docs/api/rest.rst example responses.
131+
# Each is anchored on its adjacent "name" key so the SOVD API "version":
132+
# "1.0.0" (which has neither anchor) is never rewritten:
133+
# - root "/" response: "name": "ROS 2 Medkit Gateway" then "version"
134+
# - version-info vendor_info: "version" then "name": "ros2_medkit"
135+
if [ -f "$REST_RST" ]; then
136+
REST_TARGET="$target_version" perl -0pi -e '
137+
my $v = $ENV{REST_TARGET};
138+
s/("name": "ROS 2 Medkit Gateway",\s*\n\s*"version": ")\d+\.\d+\.\d+(")/$1$v$2/g;
139+
s/("version": ")\d+\.\d+\.\d+(",\s*\n\s*"name": "ros2_medkit")/$1$v$2/g;
140+
' "$REST_RST"
141+
echo " docs/api/rest.rst example versions: -> ${target_version}"
142+
fi
143+
129144
echo ""
130145
echo "Bumped ${count} packages + version.hpp + docs to ${target_version}."
131146
echo ""
@@ -222,8 +237,38 @@ cmd_verify() {
222237
versions_seen+=("$qd_version")
223238
fi
224239

240+
# Check docs/api/rest.rst example-response versions (gateway version only;
241+
# the SOVD API "version": "1.0.0" is excluded via the same name anchors as
242+
# the bump path, so it is neither rewritten nor verified here).
243+
if [ -f "$REST_RST" ]; then
244+
local rest_versions
245+
rest_versions=$(perl -0ne '
246+
while (/"name": "ROS 2 Medkit Gateway",\s*\n\s*"version": "(\d+\.\d+\.\d+)"/g) { print "$1\n" }
247+
while (/"version": "(\d+\.\d+\.\d+)",\s*\n\s*"name": "ros2_medkit"/g) { print "$1\n" }
248+
' "$REST_RST")
249+
[ -n "$rest_versions" ] || rest_versions="unknown"
250+
while IFS= read -r rest_version; do
251+
if [ -n "$expected_version" ] && [ "$rest_version" != "$expected_version" ]; then
252+
echo " MISMATCH: docs/api/rest.rst example version is ${rest_version}, expected ${expected_version}"
253+
all_ok=false
254+
else
255+
echo " OK: docs/api/rest.rst example version = ${rest_version}"
256+
fi
257+
versions_seen+=("$rest_version")
258+
done <<< "$rest_versions"
259+
fi
260+
225261
# Check consistency if no expected version given
226262
if [ -z "$expected_version" ]; then
263+
# An "unknown" means a version pattern failed to match in some file.
264+
# Without this guard an all-"unknown" run collapses to one unique value
265+
# and would false-pass the consistency check below.
266+
if printf '%s\n' "${versions_seen[@]}" | grep -qx "unknown"; then
267+
echo ""
268+
echo "ERROR: could not parse a version from one or more files (got 'unknown')."
269+
all_ok=false
270+
fi
271+
227272
local unique_versions
228273
unique_versions=$(printf '%s\n' "${versions_seen[@]}" | sort -u)
229274
local unique_count

0 commit comments

Comments
 (0)