Fix install script: use git tags API with version sorting instead of releases API (works around Gitea epoch-zero timestamp bug)

This commit is contained in:
Laan Tungir
2026-07-16 16:13:11 -04:00
parent 8015742e29
commit 1cf541b02d

View File

@@ -84,12 +84,21 @@ resolve_nsigner_version() {
headers=(-H "Authorization: token ${NSIGNER_GITEA_TOKEN}")
fi
latest_tag="$(curl -fsSL "${headers[@]}" "https://git.laantungir.net/api/v1/repos/laantungir/n_signer/releases" \
| jq -r '.[0].tag_name // empty' || true)"
# Use the git tags API and sort by version number, instead of the releases
# API which sorts by created_at timestamp. Gitea has a bug where some
# releases get epoch-zero timestamps and don't appear in the releases list.
latest_tag="$(curl -fsSL "${headers[@]}" "https://git.laantungir.net/api/v1/repos/laantungir/n_signer/tags?limit=50" \
| jq -r '[.[].name] | map(select(startswith("v"))) | sort_by(ltrimstr("v") | split(".") | map(tonumber)) | last // empty' || true)"
if [[ -z "${latest_tag}" ]]; then
# Fallback: try the releases API (old behavior)
latest_tag="$(curl -fsSL "${headers[@]}" "https://git.laantungir.net/api/v1/repos/laantungir/n_signer/releases" \
| jq -r '.[0].tag_name // empty' || true)"
fi
if [[ -z "${latest_tag}" ]]; then
err "Could not resolve latest n_signer release tag from API."
err "Set NSIGNER_VERSION explicitly (e.g. NSIGNER_VERSION=v0.0.11)."
err "Set NSIGNER_VERSION explicitly (e.g. NSIGNER_VERSION=v0.0.46)."
exit 1
fi