Skip to content

Commit dc3754a

Browse files
committed
Fix release script consistency issues
1 parent e6f327e commit dc3754a

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

dev-bin/release.sh

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ set -eu -o pipefail
66
# before making any changes to the repository
77

88
check_command() {
9-
if ! command -v "$1" &> /dev/null; then
9+
if ! command -v "$1" &>/dev/null; then
1010
echo "Error: $1 is not installed or not in PATH"
1111
exit 1
1212
fi
1313
}
1414

1515
# Verify gh CLI is authenticated
16-
if ! gh auth status &> /dev/null; then
16+
if ! gh auth status &>/dev/null; then
1717
echo "Error: gh CLI is not authenticated. Run 'gh auth login' first."
1818
exit 1
1919
fi
2020

2121
# Verify we can access this repository via gh
22-
if ! gh repo view --json name &> /dev/null; then
22+
if ! gh repo view --json name &>/dev/null; then
2323
echo "Error: Cannot access repository via gh. Check your authentication and repository access."
2424
exit 1
2525
fi
2626

2727
# Verify git can connect to the remote (catches SSH key issues, etc.)
28-
if ! git ls-remote origin &> /dev/null; then
28+
if ! git ls-remote origin &>/dev/null; then
2929
echo "Error: Cannot connect to git remote. Check your git credentials/SSH keys."
3030
exit 1
3131
fi
@@ -54,24 +54,24 @@ fi
5454

5555
changelog=$(cat Changes.md)
5656

57-
regex='## ([0-9]+\.[0-9]+\.[0-9]+) - ([0-9]{4}-[0-9]{2}-[0-9]{2})
57+
regex='## ([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?) - ([0-9]{4}-[0-9]{2}-[0-9]{2})
5858
5959
((.|
6060
)*)
6161
'
6262

6363
if [[ ! $changelog =~ $regex ]]; then
64-
echo "Could not find date line in change log!"
65-
exit 1
64+
echo "Could not find date line in change log!"
65+
exit 1
6666
fi
6767

6868
version="${BASH_REMATCH[1]}"
69-
date="${BASH_REMATCH[2]}"
70-
notes="$(echo "${BASH_REMATCH[3]}" | sed -n -e '/^## [0-9]\+\.[0-9]\+\.[0-9]\+/,$!p')"
69+
date="${BASH_REMATCH[3]}"
70+
notes="$(echo "${BASH_REMATCH[4]}" | sed -n -E '/^## [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?/,$!p')"
7171

7272
dist="libmaxminddb-$version.tar.gz"
7373

74-
if [[ "$date" != $(date +"%Y-%m-%d") ]]; then
74+
if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then
7575
echo "$date is not today!"
7676
exit 1
7777
fi
@@ -81,7 +81,8 @@ if [ -n "$(git status --porcelain)" ]; then
8181
exit 1
8282
fi
8383

84-
old_version=$(perl -MFile::Slurp=read_file <<EOF
84+
old_version=$(
85+
perl -MFile::Slurp=read_file <<EOF
8586
use v5.16;
8687
my \$conf = read_file(q{configure.ac});
8788
\$conf =~ /AC_INIT.+\[(\d+\.\d+\.\d+)\]/;
@@ -95,7 +96,7 @@ perl -MFile::Slurp=edit_file -e \
9596
if [ -n "$(git status --porcelain)" ]; then
9697
git diff
9798

98-
read -e -p "Commit changes? " should_commit
99+
read -r -e -p "Commit changes? (y/n) " should_commit
99100

100101
if [ "$should_commit" != "y" ]; then
101102
echo "Aborting"
@@ -129,30 +130,30 @@ if [ -n "$(git status --porcelain)" ]; then
129130
fi
130131

131132
index=index.md
132-
cat <<EOF > $index
133+
cat <<EOF >$index
133134
---
134135
layout: default
135136
title: libmaxminddb - a library for working with MaxMind DB files
136137
version: $version
137138
---
138139
EOF
139140

140-
cat ../doc/libmaxminddb.md >> $index
141+
cat ../doc/libmaxminddb.md >>$index
141142

142143
mmdblookup=mmdblookup.md
143-
cat <<EOF > $mmdblookup
144+
cat <<EOF >$mmdblookup
144145
---
145146
layout: default
146147
title: mmdblookup - a utility to look up an IP address in a MaxMind DB file
147148
version: $version
148149
---
149150
EOF
150151

151-
cat ../doc/mmdblookup.md >> $mmdblookup
152+
cat ../doc/mmdblookup.md >>$mmdblookup
152153

153154
git commit -m "Updated for $version" -a
154155

155-
read -p "Push to origin? (y/n) " should_push
156+
read -r -e -p "Push to origin? (y/n) " should_push
156157

157158
if [ "$should_push" != "y" ]; then
158159
echo "Aborting"

0 commit comments

Comments
 (0)