Skip to content

fix(versioncheck): pick semver-max instead of first stable tag - #5

Merged
tazhate merged 1 commit into
masterfrom
fix/versioncheck-semver-compare
Jun 14, 2026
Merged

fix(versioncheck): pick semver-max instead of first stable tag#5
tazhate merged 1 commit into
masterfrom
fix/versioncheck-semver-compare

Conversation

@tazhate

@tazhate tazhate commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • cmd/versioncheck was treating LatestTags() results as already ordered newest-first and breaking on the first stable hit. None of our three registry clients actually guarantee that ordering:
    • Docker Hub sorts by tag_last_pushed — late patches on old branches outrank the real latest
    • GHCR tags/list and OCI v2 tags/list don't define order at all
  • Added registry.Newest() (semver-max with prefix stripping, skips unparseable tags) + 6 test cases incl. CalVer
  • checkVersions now collects all stable tags and calls Newest()
  • Narrowed .gitignore so the rule for the compiled binary doesn't also ignore the cmd/versioncheck/ source dir

Before / after on real chains

chain before after actual latest in registry
bitcoin v27.2 ← reported v28.0 ✓ v28.0
ton v2024.08 ← reported v2025.03 v2026.02-1 (caught)
gravity-alpha v2.3.3 v3.6.8 ✓ v3.6.8
cosmos v19.0.0 v25.2.0 v27.0.0 (caught)
opbnb v0.2.0 v0.4.1 v0.5.2 (caught)
goat v0.1.0 v0.4.2 ✓ v0.4.2

Not fixed by this PR

Some chains still report a too-old latest (harmony v4 vs real v8, bsc 1.3 vs real 1.6, klaytn v1.12 vs real v2.2). Root cause is different — Docker Hub returns 50 tags per page and the real latest isn't in the first page when the repo has thousands of historical tags. That's a registry-client pagination fix, separate PR.

Test plan

  • go test ./internal/registry/... — 9 pass (3 existing + 6 new for Newest)
  • go build ./...
  • go run ./cmd/versioncheck — visually verified bitcoin/ton/cosmos/goat/etc. now report correct max
  • CI green

cmd/versioncheck was treating LatestTags() as ordered newest-first
and taking the first stable entry. Three of the registries don't
honor that:

- Docker Hub sorts by tag_last_pushed, so a late patch on an old
  branch ranks above the real latest (bitcoin: v27.2 ahead of v28.0)
- GHCR and OCI v2 tags/list don't define order at all

Net effect: ~12 chains were silently marked "up to date" against a
fake latest (bitcoin, bsc, cardano, cosmos, harmony, klaytn, opbnb,
mantle, ton, goat, gravity-alpha, etc.). Mostly harmless for now
because the real latest is genuinely newer, but it hides real
updates behind false confidence.

Added registry.Newest() — picks semver-max from a slice, skipping
unparseable tags. Caller still strips pre-releases first. Updated
checkVersions to collect all stable tags into a slice and call
Newest(), instead of break-on-first.

Re-running cmd/versioncheck shows the expected fixes:
- bitcoin   v28.0 -> v28.0 (was v27.2)
- ton       v2026.02-1 -> v2025.03 (was v2024.08)
- gravity-alpha v3.6.8 -> v3.6.8 (was v2.3.3)
- cosmos    v27.0.0 -> v25.2.0 (was v19.0.0)
- opbnb     v0.5.2 -> v0.4.1 (was v0.2.0)
- goat      v0.4.2 -> v0.4.2 (was v0.1.0)

Some chains still report a too-old latest (harmony, bsc 1.3 vs real
1.6.x) — those are pagination issues in the registry clients, the
real latest just isn't in the first 50 tags Docker Hub returns.
That's a separate fix.

Also narrowed .gitignore "versioncheck" -> "/versioncheck" so the
pattern matches only the root-level compiled binary, not the
cmd/versioncheck/ source dir (git refused to add main.go otherwise).

Context: traced bitcoin's "up to date v28.0 vs v27.2" output back
to checkVersions(); read internal/registry/{client,dockerhub,ghcr,
oci}.go to confirm none of them sort by semver; added 6 test cases
for Newest including CalVer (TON-style v2026.02), prefix stripping,
and unparseable-tag skipping. ~45 min total.
@tazhate
tazhate merged commit d0f4093 into master Jun 14, 2026
0 of 9 checks passed
@tazhate
tazhate deleted the fix/versioncheck-semver-compare branch June 14, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant