doltgres-version-check.sh57 lines · main
| 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 | |
| 17 | set -euo pipefail |
| 18 | |
| 19 | COMPOSE="${BRIVEN_COMPOSE_FILE:-$(cd "$(dirname "$0")/.." && pwd)/infra/dokploy/compose.dokploy.yml}" |
| 20 | |
| 21 | # --- our pinned version (from the compose image tag) --- |
| 22 | PINNED="$(grep -oE 'dolthub/doltgresql:[0-9]+\.[0-9]+\.[0-9]+' "$COMPOSE" | head -1 | cut -d: -f2 || true)" |
| 23 | if [[ -z "$PINNED" ]]; then |
| 24 | echo "!! could not read a pinned dolthub/doltgresql:<version> tag from $COMPOSE" |
| 25 | echo " (is it still pinned by @sha256 digest? switch to a version tag — see KB)" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | # --- latest upstream release tag --- |
| 30 | LATEST="$(curl -fsSL --max-time 20 https://api.github.com/repos/dolthub/doltgresql/releases/latest \ |
| 31 | | grep -oE '"tag_name"[[:space:]]*:[[:space:]]*"v?[0-9]+\.[0-9]+\.[0-9]+"' \ |
| 32 | | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true)" |
| 33 | if [[ -z "$LATEST" ]]; then |
| 34 | echo "!! could not fetch latest doltgresql release from GitHub"; exit 1 |
| 35 | fi |
| 36 | |
| 37 | echo "Doltgres pinned (ours): $PINNED" |
| 38 | echo "Doltgres latest (upstream): $LATEST" |
| 39 | |
| 40 | # --- compare (sort -V) --- |
| 41 | if [[ "$PINNED" == "$LATEST" ]]; then |
| 42 | echo "✓ up to date." |
| 43 | exit 0 |
| 44 | fi |
| 45 | newest="$(printf '%s\n%s\n' "$PINNED" "$LATEST" | sort -V | tail -1)" |
| 46 | if [[ "$newest" == "$PINNED" ]]; then |
| 47 | echo "✓ our pin is ahead of/equal to latest release (pre-release?). No action." |
| 48 | exit 0 |
| 49 | fi |
| 50 | |
| 51 | echo |
| 52 | echo "⚠ NEWER Doltgres available: $PINNED -> $LATEST" |
| 53 | echo " Release notes: https://github.com/dolthub/doltgresql/releases/tag/v$LATEST" |
| 54 | echo " Open issues: https://github.com/dolthub/doltgresql/issues" |
| 55 | echo " To upgrade: follow docs/knowledge-base.md → 'Doltgres version pinning + upgrade process'" |
| 56 | echo " (validate data-read on a throwaway first; keep auto_gc_behavior.enable:false)" |
| 57 | exit 10 |