@@ -6,26 +6,26 @@ set -eu -o pipefail
66# before making any changes to the repository
77
88check_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
1919fi
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
2525fi
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
3131fi
5454
5555changelog=$( 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
6363if [[ ! $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
6666fi
6767
6868version=" ${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
7272dist=" 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
7777fi
@@ -81,7 +81,8 @@ if [ -n "$(git status --porcelain)" ]; then
8181 exit 1
8282fi
8383
84- old_version=$( perl -MFile::Slurp=read_file << EOF
84+ old_version=$(
85+ perl -MFile::Slurp=read_file << EOF
8586use v5.16;
8687my \$ conf = read_file(q{configure.ac});
8788\$ conf =~ /AC_INIT.+\[(\d+\.\d+\.\d+)\]/;
@@ -95,7 +96,7 @@ perl -MFile::Slurp=edit_file -e \
9596if [ -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
129130fi
130131
131132index=index.md
132- cat << EOF > $index
133+ cat << EOF >$index
133134---
134135layout: default
135136title: libmaxminddb - a library for working with MaxMind DB files
136137version: $version
137138---
138139EOF
139140
140- cat ../doc/libmaxminddb.md >> $index
141+ cat ../doc/libmaxminddb.md >> $index
141142
142143mmdblookup=mmdblookup.md
143- cat << EOF > $mmdblookup
144+ cat << EOF >$mmdblookup
144145---
145146layout: default
146147title: mmdblookup - a utility to look up an IP address in a MaxMind DB file
147148version: $version
148149---
149150EOF
150151
151- cat ../doc/mmdblookup.md >> $mmdblookup
152+ cat ../doc/mmdblookup.md >> $mmdblookup
152153
153154git 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
157158if [ " $should_push " != " y" ]; then
158159 echo " Aborting"
0 commit comments