-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrelease-utils.sh
More file actions
executable file
·580 lines (500 loc) · 21.6 KB
/
Copy pathrelease-utils.sh
File metadata and controls
executable file
·580 lines (500 loc) · 21.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
#!/usr/bin/env bash
# release-utils.sh - Unified utilities for version/changelog management
# Provides extensible tool registry and common functions for version checking
set -euo pipefail
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Colors
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
RESET='\033[0m'
BOLD='\033[1m'
DIM='\033[0;90m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[1;36m'
WHITE='\033[1;37m'
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Tool Registry
# Each tool: NAME|TYPE|SOURCE|LABEL|URL|CHANGELOG_URL|GROUP|IMAGE
# TYPE: npm, github-release, github-commit
# GROUP: agent, browser, toolchain, runtime
# (subsets for `make <group>-up` scoped bumps)
# IMAGE: base, main, rust
# (which Dockerfile stage contains the tool; drives rebuild-skip)
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
TOOL_REGISTRY=(
"claude-code|npm|@anthropic-ai/claude-code|org.opencontainers.image.claude_code_version|https://www.npmjs.com/package/@anthropic-ai/claude-code|https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md|agent|main"
"codex|npm|@openai/codex|org.opencontainers.image.codex_version|https://www.npmjs.com/package/@openai/codex|github:openai/codex|agent|main"
"gemini-cli|npm|@google/gemini-cli|org.opencontainers.image.gemini_cli_version|https://www.npmjs.com/package/@google/gemini-cli||agent|main"
"grok-cli|npm|@xai-official/grok|org.opencontainers.image.grok_cli_version|https://www.npmjs.com/package/@xai-official/grok||agent|main"
"ccx|github-release|thevibeworks/ccx|org.opencontainers.image.ccx_version|https://github.com/thevibeworks/ccx|github:thevibeworks/ccx|agent|main"
"copilot-api|github-commit|ericc-ch/copilot-api|org.opencontainers.image.copilot_api_version|https://github.com/ericc-ch/copilot-api||agent|main"
"cctrace|npm|@thevibeworks/cctrace|org.opencontainers.image.cctrace_version|https://www.npmjs.com/package/@thevibeworks/cctrace|github:thevibeworks/cctrace|agent|main"
"playwright|npm|playwright|org.opencontainers.image.playwright_version|https://www.npmjs.com/package/playwright|github:microsoft/playwright|browser|rust"
)
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Tool Registry Helpers
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
get_tool_field() {
local tool=$1 field=$2
local name type source label url changelog group image entry
for entry in "${TOOL_REGISTRY[@]}"; do
IFS='|' read -r name type source label url changelog group image <<< "$entry"
if [[ $name == "$tool" ]]; then
case $field in
name) echo "$name" ;;
type) echo "$type" ;;
source) echo "$source" ;;
label) echo "$label" ;;
url) echo "$url" ;;
changelog) echo "$changelog" ;;
group) echo "$group" ;;
image) echo "$image" ;;
esac
return 0
fi
done
return 1
}
get_all_tools() {
local name entry
for entry in "${TOOL_REGISTRY[@]}"; do
IFS='|' read -r name _ <<< "$entry"
echo "$name"
done
}
get_tools_by_group() {
local want=$1
local name group entry
for entry in "${TOOL_REGISTRY[@]}"; do
IFS='|' read -r name _ _ _ _ _ group _ <<< "$entry"
[[ $group == "$want" ]] && echo "$name"
done
}
get_tools_by_image() {
local want=$1
local name image entry
for entry in "${TOOL_REGISTRY[@]}"; do
IFS='|' read -r name _ _ _ _ _ _ image <<< "$entry"
[[ $image == "$want" ]] && echo "$name"
done
}
# Resolve the active tool set honoring exactly one scope knob.
# Reads GROUP / TOOL / IMAGE from the environment. Setting more than one
# is a design error — callers must pick a single scope.
#
# Output: one tool name per line. Empty output means no tools matched
# (valid, e.g. IMAGE=base before toolchain pins land).
filter_tools() {
local set_count=0
[[ -n ${GROUP:-} ]] && set_count=$((set_count + 1))
[[ -n ${TOOL:-} ]] && set_count=$((set_count + 1))
[[ -n ${IMAGE:-} ]] && set_count=$((set_count + 1))
if [[ $set_count -gt 1 ]]; then
echo "error: GROUP, TOOL, and IMAGE are mutually exclusive — pick one" >&2
return 2
fi
if [[ -n ${TOOL:-} ]]; then
if ! get_tool_field "$TOOL" name >/dev/null; then
echo "error: unknown tool: $TOOL" >&2
return 2
fi
echo "$TOOL"
elif [[ -n ${GROUP:-} ]]; then
get_tools_by_group "$GROUP"
elif [[ -n ${IMAGE:-} ]]; then
get_tools_by_image "$IMAGE"
else
get_all_tools
fi
}
# Collect the set of IMAGE values touched by a list of tools on stdin.
# Drives rebuild-skip logic: only rebuild images whose contents changed.
images_for_tools() {
local tool
while IFS= read -r tool; do
[[ -z $tool ]] && continue
get_tool_field "$tool" image
done | sort -u
}
get_display_name() {
local tool=$1
case $tool in
claude-code) echo "Claude Code" ;;
codex) echo "Codex" ;;
gemini-cli) echo "Gemini CLI" ;;
grok-cli) echo "Grok CLI" ;;
ccx) echo "CCX" ;;
copilot-api) echo "Copilot API" ;;
playwright) echo "Playwright" ;;
*) echo "$tool" ;;
esac
}
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Version Utilities
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
normalize_version() {
local v=$1
v=${v#v}
echo "$v"
}
format_version() {
local v=$1
if [[ -z $v ]] || [[ $v == "<no value>" ]]; then
echo "-"
elif [[ $v == v* ]]; then
echo "$v"
else
echo "v$v"
fi
}
format_datetime() {
local datetime=$1
[[ -z $datetime ]] && return
date -d "$datetime" '+%b %d, %Y %H:%M' 2>/dev/null || \
date -jf '%Y-%m-%dT%H:%M:%SZ' "$datetime" '+%b %d, %Y %H:%M' 2>/dev/null || \
date -jf '%Y-%m-%dT%H:%M:%S' "${datetime%.*}" '+%b %d, %Y %H:%M' 2>/dev/null || \
echo "$datetime"
}
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Version Fetching (by type)
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
_npm_registry_latest() {
curl -fsSL --max-time 10 \
"https://registry.npmjs.org/-/package/$1/dist-tags" 2>/dev/null | \
sed -n 's/.*"latest":"\([^"]*\)".*/\1/p'
}
fetch_latest_version() {
local tool=$1
local type=$(get_tool_field "$tool" type)
local source=$(get_tool_field "$tool" source)
case $type in
npm)
# Soft-fail like the gh arms below: a transient registry error
# must reach load_versions' warn-and-fallback path, not abort
# the whole run under set -e.
_npm_registry_latest "$source" || echo ""
;;
github-release)
gh api "repos/$source/releases/latest" --jq '.tag_name' 2>/dev/null || echo ""
;;
github-commit)
local branch="master"
[[ $source == "thevibeworks/ccx" ]] && branch="main"
gh api "repos/$source/branches/$branch" --jq '.commit.sha' 2>/dev/null || echo ""
;;
esac
}
fetch_version_date() {
local tool=$1 version=$2
local type=$(get_tool_field "$tool" type)
local source=$(get_tool_field "$tool" source)
case $type in
npm)
local v=$(normalize_version "$version")
local encoded=${source/\//%2f}
curl -fsSL --max-time 10 "https://registry.npmjs.org/$encoded" 2>/dev/null | \
jq -r --arg ver "$v" '.time[$ver] // empty' 2>/dev/null | head -1 || echo ""
;;
github-release)
gh api "repos/$source/releases/tags/$version" --jq '.published_at' 2>/dev/null || echo ""
;;
github-commit)
gh api "repos/$source/commits/$version" --jq '.commit.committer.date' 2>/dev/null || echo ""
;;
esac
}
get_image_version() {
local image=$1 label=$2
docker inspect "$image" 2>/dev/null | \
jq -r --arg k "$label" '.[0].Config.Labels[$k] // ""' 2>/dev/null || echo ""
}
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Changelog Fetching
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
fetch_changelog() {
local tool=$1 current=$2 latest=$3
local changelog_source=$(get_tool_field "$tool" changelog)
[[ -z $changelog_source ]] && return
[[ -z $current ]] || [[ $current == "-" ]] && return
current=$(normalize_version "$current")
latest=$(normalize_version "$latest")
[[ $current == "$latest" ]] && return
if [[ $changelog_source == github:* ]]; then
fetch_github_releases "${changelog_source#github:}" "$current" "$latest"
else
fetch_markdown_changelog "$changelog_source" "$current" "$latest"
fi
}
fetch_markdown_changelog() {
local url=$1 current=$2 latest=$3
local data
data=$(curl -fsSL --max-time 10 --retry 2 "$url" 2>/dev/null) || { echo "(fetch failed)"; return 0; }
python3 -c '
import re, sys
def parse_version(v):
parts = re.findall(r"\d+", v)
return tuple(int(p) for p in parts) if parts else (0,)
current, latest = sys.argv[1], sys.argv[2]
text = sys.stdin.read()
try:
cur_v, lat_v = parse_version(current), parse_version(latest)
except:
sys.exit(0)
sections = re.split(r"(?=^## )", text, flags=re.M)
changes = []
for section in sections:
if not section.strip():
continue
match = re.match(r"^##\s+.*?(\d+\.\d+\.\d+)", section, re.M)
if not match:
continue
try:
v = parse_version(match.group(1))
if cur_v < v <= lat_v:
lines = section.strip().split("\n")
output = [lines[0].replace("## ", "")]
content_lines = [l for l in lines[1:] if l.strip()][:10]
output.extend(content_lines)
changes.append("\n".join(output))
except:
continue
for change in reversed(changes[-3:]):
print(change)
print()
' "$current" "$latest" <<< "$data" 2>/dev/null || true
}
fetch_github_releases() {
local repo=$1 current=$2 latest=$3
local json
json=$(gh api "repos/$repo/releases" 2>/dev/null) || { echo "(fetch failed)"; return 0; }
python3 -c '
import json, sys, re
def parse_version(v):
match = re.search(r"(\d+)\.(\d+)\.(\d+)", v)
return tuple(int(x) for x in match.groups()) if match else (0, 0, 0)
current, latest = sys.argv[1], sys.argv[2]
releases = json.load(sys.stdin)
try:
cur_v, lat_v = parse_version(current), parse_version(latest)
except:
sys.exit(0)
changes = []
seen = set()
for rel in releases:
if rel.get("prerelease"):
continue
tag = rel.get("tag_name", "")
if not tag:
continue
try:
v = parse_version(tag)
if v in seen or not (cur_v < v <= lat_v):
continue
seen.add(v)
ver = re.search(r"(\d+\.\d+\.\d+)", tag)
ver = ver.group(1) if ver else tag
body = (rel.get("body") or "").replace("\r\n", "\n").strip()
changes.append((v, ver, body))
except:
continue
for v, ver, body in sorted(changes, key=lambda x: x[0], reverse=True)[:3]:
print(f"{ver}")
if body:
for line in [l.rstrip() for l in body.split("\n") if l.strip()][:15]:
print(f" {line}")
print()
' "$current" "$latest" <<< "$json" 2>/dev/null || true
}
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Display Helpers
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
section() {
echo -e "${CYAN}${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
echo -e "${CYAN}${BOLD}$1${RESET}"
echo -e "${CYAN}${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
}
indent() { sed 's/^/ /'; }
print_version_line() {
local tool=$1 current=$2 latest=$3 date=$4
local name=$(get_display_name "$tool")
local url=$(get_tool_field "$tool" url)
local type=$(get_tool_field "$tool" type)
local cur_fmt lat_fmt
if [[ $type == "github-commit" ]]; then
cur_fmt="${current:0:7}"
lat_fmt="${latest:0:7}"
[[ -z $current ]] || [[ $current == "-" ]] && cur_fmt="-"
else
cur_fmt=$(format_version "$current")
lat_fmt=$(format_version "$latest")
fi
local date_str=""
[[ -n $date ]] && date_str=" ${DIM}($(format_datetime "$date"))${RESET}"
local link_str=""
[[ -n $url ]] && link_str=" ${DIM}${url}${RESET}"
local pad=$(printf "%-12s" "$name:")
if [[ -z $current ]] || [[ $current == "-" ]]; then
echo -e " ${WHITE}${pad}${RESET} ${DIM}-${RESET} -> ${GREEN}${lat_fmt}${RESET}${date_str}${link_str} ${YELLOW}(not built)${RESET}"
return 1
elif [[ $(normalize_version "$current") == $(normalize_version "$latest") ]] || [[ $current == "$latest" ]]; then
echo -e " ${DIM}${pad} ${lat_fmt}${RESET}${date_str}${link_str} ${GREEN}(up-to-date)${RESET}"
return 0
else
echo -e " ${WHITE}${pad}${RESET} ${RED}${cur_fmt}${RESET} -> ${GREEN}${lat_fmt}${RESET}${date_str}${link_str}"
return 1
fi
}
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Version Storage (bash 3.2 compatible - no associative arrays)
# Uses naming convention: _VER_{CURRENT,LATEST,DATE}_{tool_key}
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
tool_key() {
echo "$1" | tr '-' '_'
}
set_current() { eval "_VER_CURRENT_$(tool_key "$1")=\"$2\""; }
set_latest() { eval "_VER_LATEST_$(tool_key "$1")=\"$2\""; }
set_date() { eval "_VER_DATE_$(tool_key "$1")=\"$2\""; }
get_current() { eval "echo \"\${_VER_CURRENT_$(tool_key "$1"):-}\""; }
get_latest() { eval "echo \"\${_VER_LATEST_$(tool_key "$1"):-}\""; }
get_date() { eval "echo \"\${_VER_DATE_$(tool_key "$1"):-}\""; }
load_versions() {
local image=$1
echo -e "${DIM}Fetching versions...${RESET}"
for tool in $(get_all_tools); do
local label=$(get_tool_field "$tool" label)
# Rust-only tools are absent from main image; query the rust image instead.
local query_image=$image
[[ $tool == "playwright" ]] && query_image="${RUST_IMAGE:-ghcr.io/thevibeworks/deva:rust}"
# Current from image
if docker inspect "$query_image" >/dev/null 2>&1; then
set_current "$tool" "$(get_image_version "$query_image" "$label")"
else
set_current "$tool" ""
fi
# Always fetch latest from upstream. versions.env populates env vars
# unconditionally, so checking them here would compare pin-vs-pin and
# always report "up-to-date". CLI overrides are respected at BUILD
# time (version-upgrade.sh), not at CHECK time.
local fetched
fetched=$(fetch_latest_version "$tool")
if [[ -n $fetched ]]; then
set_latest "$tool" "$fetched"
else
local current=$(get_current "$tool")
if [[ -n $current ]]; then
echo -e "${YELLOW}Warning: Failed to fetch latest $tool, using current: $current${RESET}" >&2
set_latest "$tool" "$current"
else
echo -e "${RED}Error: Cannot determine version for $tool${RESET}" >&2
fi
fi
set_date "$tool" "$(fetch_version_date "$tool" "$(get_latest "$tool")")"
done
}
print_version_summary() {
echo ""
echo -e "${YELLOW}${BOLD}Version Status${RESET}"
echo ""
local needs_update=0
for tool in $(get_all_tools); do
print_version_line "$tool" "$(get_current "$tool")" "$(get_latest "$tool")" "$(get_date "$tool")" || needs_update=1
done
echo ""
return $needs_update
}
print_changelogs() {
for tool in $(get_all_tools); do
local current=$(get_current "$tool")
local latest=$(get_latest "$tool")
local changelog_source=$(get_tool_field "$tool" changelog)
[[ -z $changelog_source ]] && continue
[[ -z $current ]] || [[ $current == "-" ]] && continue
local cur_norm=$(normalize_version "$current")
local lat_norm=$(normalize_version "$latest")
[[ $cur_norm == "$lat_norm" ]] && continue
local name=$(get_display_name "$tool")
section "$name Changelog"
local changes
changes=$(fetch_changelog "$tool" "$current" "$latest")
if [[ -n $changes ]]; then
echo "$changes" | indent
else
echo -e " ${DIM}(changelog unavailable)${RESET}"
fi
echo ""
done
}
# Show recent changelogs for all tools (regardless of update status)
print_recent_changelogs() {
local depth=${CHANGELOG_DEPTH:-3}
for tool in $(get_all_tools); do
local changelog_source=$(get_tool_field "$tool" changelog)
[[ -z $changelog_source ]] && continue
local name=$(get_display_name "$tool")
local latest=$(get_latest "$tool")
section "$name (latest: $latest)"
local changes=""
if [[ $changelog_source == github:* ]]; then
changes=$(fetch_recent_github_releases "${changelog_source#github:}" "$depth")
else
changes=$(fetch_recent_markdown_changelog "$changelog_source" "$depth")
fi
if [[ -n $changes ]]; then
echo "$changes" | indent
else
echo -e " ${DIM}(changelog unavailable)${RESET}"
fi
echo ""
done
}
fetch_recent_markdown_changelog() {
local url=$1 count=${2:-3}
local data
data=$(curl -fsSL --max-time 10 --retry 2 "$url" 2>/dev/null) || { echo "(fetch failed)"; return 0; }
python3 -c '
import re, sys
count = int(sys.argv[1])
text = sys.stdin.read()
sections = re.split(r"(?=^## )", text, flags=re.M)
printed = 0
for section in sections:
if not section.strip() or printed >= count:
continue
match = re.match(r"^##\s+.*?(\d+\.\d+\.\d+)", section, re.M)
if not match:
continue
lines = section.strip().split("\n")
print(lines[0].replace("## ", ""))
for line in [l for l in lines[1:] if l.strip()][:8]:
print(line)
print()
printed += 1
' "$count" <<< "$data" 2>/dev/null || true
}
fetch_recent_github_releases() {
local repo=$1 count=${2:-3}
local json
json=$(gh api "repos/$repo/releases?per_page=$count" 2>/dev/null) || { echo "(fetch failed)"; return 0; }
python3 -c '
import json, sys, re
count = int(sys.argv[1])
releases = json.load(sys.stdin)
printed = 0
for rel in releases:
if rel.get("prerelease") or printed >= count:
continue
tag = rel.get("tag_name", "")
if not tag:
continue
ver = re.search(r"(\d+\.\d+\.\d+)", tag)
ver = ver.group(1) if ver else tag
body = (rel.get("body") or "").replace("\r\n", "\n").strip()
print(ver)
if body:
for line in [l.rstrip() for l in body.split("\n") if l.strip()][:12]:
print(f" {line}")
print()
printed += 1
' "$count" <<< "$json" 2>/dev/null || true
}