fix(versioncheck): pick semver-max instead of first stable tag - #5
Merged
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cmd/versioncheckwas treatingLatestTags()results as already ordered newest-first and breaking on the first stable hit. None of our three registry clients actually guarantee that ordering:tag_last_pushed— late patches on old branches outrank the real latesttags/listand OCI v2tags/listdon't define order at allregistry.Newest()(semver-max with prefix stripping, skips unparseable tags) + 6 test cases incl. CalVercheckVersionsnow collects all stable tags and callsNewest().gitignoreso the rule for the compiled binary doesn't also ignore thecmd/versioncheck/source dirBefore / after on real chains
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 forNewest)go build ./...go run ./cmd/versioncheck— visually verified bitcoin/ton/cosmos/goat/etc. now report correct max