|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# update_docs_version.sh β Sync the example GizmoSQL version strings in the |
| 4 | +# Quick Start docs (docs/quickstart.md) to the latest released version. |
| 5 | +# |
| 6 | +# These are illustrative output snippets (the server startup banner and the |
| 7 | +# GIZMOSQL_VERSION() result), so they should always reflect the current |
| 8 | +# release. This script is run automatically by the `sync-docs-version` CI job |
| 9 | +# on every tag push, and can also be run by hand: |
| 10 | +# |
| 11 | +# scripts/update_docs_version.sh # uses the latest git tag |
| 12 | +# scripts/update_docs_version.sh v1.28.0 # explicit version |
| 13 | +# |
| 14 | +# It only rewrites the version token in two well-known lines, so it is safe to |
| 15 | +# re-run and idempotent. |
| 16 | +set -euo pipefail |
| 17 | + |
| 18 | +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 19 | +QUICKSTART="${REPO_ROOT}/docs/quickstart.md" |
| 20 | + |
| 21 | +# Resolve the target version: explicit arg, else the latest git tag. |
| 22 | +VERSION="${1:-$(git -C "${REPO_ROOT}" describe --tags --abbrev=0)}" |
| 23 | +VERSION="v${VERSION#v}" # normalize so both "1.28.0" and "v1.28.0" work |
| 24 | + |
| 25 | +if [[ ! "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 26 | + echo "error: '${VERSION}' is not a vMAJOR.MINOR.PATCH version" >&2 |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +# 1. Server startup banner: "GizmoSQL server version: vX.Y.Z - with engine..." |
| 31 | +sed -i.bak -E \ |
| 32 | + "s|(GizmoSQL server version: )v[0-9]+\.[0-9]+\.[0-9]+|\1${VERSION}|" \ |
| 33 | + "${QUICKSTART}" |
| 34 | + |
| 35 | +# 2. GIZMOSQL_VERSION() result cell. The column is 18 chars wide and |
| 36 | +# left-aligned (1 leading + 1 trailing space inside the 20-wide box cell), |
| 37 | +# so regenerate the whole line with printf to keep the box drawing aligned. |
| 38 | +CELL="$(printf '%-18s' "${VERSION}")" |
| 39 | +sed -i.bak -E \ |
| 40 | + "s|^β v[0-9]+\.[0-9]+\.[0-9]+ +β Core β$|β ${CELL} β Core β|" \ |
| 41 | + "${QUICKSTART}" |
| 42 | + |
| 43 | +rm -f "${QUICKSTART}.bak" |
| 44 | + |
| 45 | +echo "Updated ${QUICKSTART#${REPO_ROOT}/} to ${VERSION}" |
0 commit comments