Skip to content

Commit bcc944a

Browse files
dunglasclaude
andauthored
chore: better preflight checks in release.sh (#2348)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 25261e5 commit bcc944a

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

release.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,30 @@ if [[ ! $1 =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]
3535
exit 1
3636
fi
3737

38-
git checkout main
39-
git pull
38+
# Pre-flight checks
39+
if [[ "$(git branch --show-current)" != "main" ]]; then
40+
echo "You must be on the main branch to release." >&2
41+
exit 1
42+
fi
43+
44+
if [[ -n "$(git status --porcelain)" ]]; then
45+
echo "Working tree is not clean. Commit or stash your changes first." >&2
46+
exit 1
47+
fi
48+
49+
git fetch origin
50+
local_head="$(git rev-parse HEAD)"
51+
remote_head="$(git rev-parse origin/main)"
52+
if [[ "$local_head" != "$remote_head" ]]; then
53+
if git merge-base --is-ancestor HEAD origin/main; then
54+
echo "Local main is behind origin/main. Pull first." >&2
55+
elif git merge-base --is-ancestor origin/main HEAD; then
56+
echo "Local main is ahead of origin/main. Push your commits or reset to origin/main before releasing." >&2
57+
else
58+
echo "Local main has diverged from origin/main. Reconcile with pull/rebase/reset before releasing." >&2
59+
fi
60+
exit 1
61+
fi
4062

4163
cd caddy/
4264
go get "github.com/dunglas/frankenphp@v$1"

0 commit comments

Comments
 (0)