doltgres-version-check.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. # Doltgres version tracker — compares our PINNED doltgresql image against the
  3. # latest upstream release, so we "move along" when DoltHub ships fixes.
  4. #
  5. # WHY: Doltgres is Beta; releases carry lock/concurrency/panic fixes we depend on
  6. # (see docs/knowledge-base.md → "INCIDENT 2026-08-01" — 0.56.6 locked under load,
  7. # fixed by upgrading to 0.57.2). This is a MANUAL, on-demand check — NOT a
  8. # Watchtower/host-side poller (forbidden by infra/CLAUDE.md). Run it locally or
  9. # from the brain cron; it never runs on the deploy host and never auto-upgrades.
  10. #
  11. # Usage: bash scripts/doltgres-version-check.sh
  12. # Exit: 0 = up to date, 10 = newer release available, 1 = error.
  13. #
  14. # On a newer release: follow the tested upgrade procedure in
  15. # docs/knowledge-base.md → "Doltgres version pinning + upgrade process".
  16. set -euo pipefail
  17. COMPOSE="${BRIVEN_COMPOSE_FILE:-$(cd "$(dirname "$0")/.." && pwd)/infra/dokploy/compose.dokploy.yml}"
  18. # --- our pinned version (from the compose image tag) ---
  19. PINNED="$(grep -oE 'dolthub/doltgresql:[0-9]+\.[0-9]+\.[0-9]+' "$COMPOSE" | head -1 | cut -d: -f2 || true)"
  20. if [[ -z "$PINNED" ]]; then
  21. echo "!! could not read a pinned dolthub/doltgresql:<version> tag from $COMPOSE"
  22. echo " (is it still pinned by @sha256 digest? switch to a version tag — see KB)"
  23. exit 1
  24. fi
  25. # --- latest upstream release tag ---
  26. LATEST="$(curl -fsSL --max-time 20 https://api.github.com/repos/dolthub/doltgresql/releases/latest \
  27. | grep -oE '"tag_name"[[:space:]]*:[[:space:]]*"v?[0-9]+\.[0-9]+\.[0-9]+"' \
  28. | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true)"
  29. if [[ -z "$LATEST" ]]; then
  30. echo "!! could not fetch latest doltgresql release from GitHub"; exit 1
  31. fi
  32. echo "Doltgres pinned (ours): $PINNED"
  33. echo "Doltgres latest (upstream): $LATEST"
  34. # --- compare (sort -V) ---
  35. if [[ "$PINNED" == "$LATEST" ]]; then
  36. echo "✓ up to date."
  37. exit 0
  38. fi
  39. newest="$(printf '%s\n%s\n' "$PINNED" "$LATEST" | sort -V | tail -1)"
  40. if [[ "$newest" == "$PINNED" ]]; then
  41. echo "✓ our pin is ahead of/equal to latest release (pre-release?). No action."
  42. exit 0
  43. fi
  44. echo
  45. echo "⚠ NEWER Doltgres available: $PINNED -> $LATEST"
  46. echo " Release notes: https://github.com/dolthub/doltgresql/releases/tag/v$LATEST"
  47. echo " Open issues: https://github.com/dolthub/doltgresql/issues"
  48. echo " To upgrade: follow docs/knowledge-base.md → 'Doltgres version pinning + upgrade process'"
  49. echo " (validate data-read on a throwaway first; keep auto_gc_behavior.enable:false)"
  50. exit 10