Skip to content

Commit 01cd2d0

Browse files
authored
Merge pull request #327 from maxmind/greg/eng-1733
Improve release script reliability (ENG-1733)
2 parents cff633d + 74879b7 commit 01cd2d0

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

dev-bin/release.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,37 @@
22

33
set -eu -o pipefail
44

5+
# Pre-flight checks - verify all required tools are available and configured
6+
# before making any changes to the repository
7+
8+
check_command() {
9+
if ! command -v "$1" &>/dev/null; then
10+
echo "Error: $1 is not installed or not in PATH"
11+
exit 1
12+
fi
13+
}
14+
15+
# Verify gh CLI is authenticated
16+
if ! gh auth status &>/dev/null; then
17+
echo "Error: gh CLI is not authenticated. Run 'gh auth login' first."
18+
exit 1
19+
fi
20+
21+
# Verify we can access this repository via gh
22+
if ! gh repo view --json name &>/dev/null; then
23+
echo "Error: Cannot access repository via gh. Check your authentication and repository access."
24+
exit 1
25+
fi
26+
27+
# Verify git can connect to the remote (catches SSH key issues, etc.)
28+
if ! git ls-remote origin &>/dev/null; then
29+
echo "Error: Cannot connect to git remote. Check your git credentials/SSH keys."
30+
exit 1
31+
fi
32+
33+
check_command perl
34+
check_command mvn
35+
536
# Check that we're not on the main branch
637
current_branch=$(git branch --show-current)
738
if [ "$current_branch" = "main" ]; then
@@ -31,15 +62,15 @@ regex='
3162
'
3263

3364
if [[ ! $changelog =~ $regex ]]; then
34-
echo "Could not find date line in change log!"
35-
exit 1
65+
echo "Could not find date line in change log!"
66+
exit 1
3667
fi
3768

3869
version="${BASH_REMATCH[1]}"
3970
date="${BASH_REMATCH[2]}"
4071
notes="$(echo "${BASH_REMATCH[3]}" | sed -n -e '/^[0-9]\+\.[0-9]\+\.[0-9]\+/,$!p')"
4172

42-
if [[ "$date" != $(date +"%Y-%m-%d") ]]; then
73+
if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then
4374
echo "$date is not today!"
4475
exit 1
4576
fi
@@ -88,7 +119,7 @@ if [ "$should_continue" != "y" ]; then
88119
fi
89120

90121
page=.gh-pages/index.md
91-
cat <<EOF > $page
122+
cat <<EOF >$page
92123
---
93124
layout: default
94125
title: MaxMind DB Java API
@@ -103,7 +134,7 @@ mvn versions:set -DnewVersion="$version"
103134
perl -pi -e "s/(?<=<version>)[^<]*/$version/" README.md
104135
perl -pi -e "s/(?<=com\.maxmind\.db\:maxmind-db\:)\d+\.\d+\.\d+([\w\-]+)?/$version/" README.md
105136

106-
cat README.md >> $page
137+
cat README.md >>$page
107138

108139
git diff
109140

0 commit comments

Comments
 (0)