diff --git a/scripts/release.sh b/scripts/release.sh index f743e7e..9d45cb0 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -23,12 +23,35 @@ set -eu # exactly what this ~30-line version replaces. CHANGELOG="CHANGELOG.md" +BASE="main" if ! command -v code >/dev/null 2>&1; then echo "Error: 'code' (VS Code CLI) not found; install it or remove the editor step." >&2 exit 1 fi +# Releases are cut from `main` (see CONTRIBUTING § Publishing workflow). Make +# that explicit rather than relying on pubv's default-branch check, so the +# error names `main` even when the remote's default is configured differently. +CURRENT=$(git symbolic-ref --quiet --short HEAD || true) +if [ "${CURRENT}" != "${BASE}" ]; then + echo "Error: releases are cut from '${BASE}', but HEAD is '${CURRENT:-detached}'." >&2 + exit 1 +fi + +# pubv decides the "default branch" by reading the *local* +# `refs/remotes/origin/HEAD`, not by asking the remote, and `git fetch` never +# updates that ref. After a default-branch change — or a clone from when the +# default was different — it goes stale and pubv warns/fails because the +# current branch (main) does not match it, even though main *is* the remote +# default. Refresh it from the remote first, so pubv's branch preflight +# compares against reality. (Without a network this fails, but so would the +# push pubv is about to do, so it is a real error rather than one to swallow.) +if ! git remote set-head origin --auto >/dev/null 2>&1; then + echo "Error: could not refresh origin/HEAD; check connectivity to origin." >&2 + exit 1 +fi + echo "Running pubv..." pubv --no-tag --no-push --tag-prefix=none