@@ -6,28 +6,28 @@ set -eu -o pipefail
66# before making any changes to the repository
77
88check_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
9+ if ! command -v " $1 " & > /dev/null; then
10+ echo " Error: $1 is not installed or not in PATH"
11+ exit 1
12+ fi
1313}
1414
1515# 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
16+ if ! gh auth status & > /dev/null; then
17+ echo " Error: gh CLI is not authenticated. Run 'gh auth login' first."
18+ exit 1
1919fi
2020
2121# 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
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
2525fi
2626
2727# 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
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
3131fi
3232
3333check_command perl
@@ -37,51 +37,52 @@ check_command autoconf
3737# Check that we're not on the main branch
3838current_branch=$( git branch --show-current)
3939if [ " $current_branch " = " main" ]; then
40- echo " Error: Releases should not be done directly on the main branch."
41- echo " Please create a release branch and run this script from there."
42- exit 1
40+ echo " Error: Releases should not be done directly on the main branch."
41+ echo " Please create a release branch and run this script from there."
42+ exit 1
4343fi
4444
4545# Fetch latest changes and check that we're not behind origin/main
4646echo " Fetching from origin..."
4747git fetch origin
4848
4949if ! git merge-base --is-ancestor origin/main HEAD; then
50- echo " Error: Current branch is behind origin/main."
51- echo " Please merge or rebase with origin/main before releasing."
52- exit 1
50+ echo " Error: Current branch is behind origin/main."
51+ echo " Please merge or rebase with origin/main before releasing."
52+ exit 1
5353fi
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
75- echo " $date is not today!"
76- exit 1
74+ if [[ " $date " != " $( date +" %Y-%m-%d" ) " ]]; then
75+ echo " $date is not today!"
76+ exit 1
7777fi
7878
7979if [ -n " $( git status --porcelain) " ]; then
80- echo " . is not clean." >&2
81- exit 1
80+ echo " . is not clean." >&2
81+ 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+)\]/;
9091)
9192
9293perl -MFile::Slurp=edit_file -e \
93- " edit_file { s/\Q$old_version /$version /g } \$ _ for qw( configure.ac include/maxminddb.h CMakeLists.txt )"
94+ " edit_file { s/\Q$old_version /$version /g } \$ _ for qw( configure.ac include/maxminddb.h CMakeLists.txt )"
9495
9596if [ -n " $( git status --porcelain) " ]; then
96- git diff
97+ git diff
9798
98- read -e -p " Commit changes? " should_commit
99+ read -r - e -p " Commit changes? (y/n) " should_commit
99100
100- if [ " $should_commit " != " y" ]; then
101- echo " Aborting"
102- exit 1
103- fi
101+ if [ " $should_commit " != " y" ]; then
102+ echo " Aborting"
103+ exit 1
104+ fi
104105
105- git add configure.ac include/maxminddb.h CMakeLists.txt
106- git commit -m " Bumped version to $version "
106+ git add configure.ac include/maxminddb.h CMakeLists.txt
107+ git commit -m " Bumped version to $version "
107108fi
108109
109110./bootstrap
@@ -114,49 +115,49 @@ make clean
114115make safedist
115116
116117if [ ! -d .gh-pages ]; then
117- echo " Checking out gh-pages in .gh-pages"
118- git clone -b gh-pages
[email protected] :maxmind/libmaxminddb.git .gh-pages
119- pushd .gh-pages
118+ echo " Checking out gh-pages in .gh-pages"
119+ git clone -b gh-pages
[email protected] :maxmind/libmaxminddb.git .gh-pages
120+ pushd .gh-pages
120121else
121- echo " Updating .gh-pages"
122- pushd .gh-pages
123- git pull
122+ echo " Updating .gh-pages"
123+ pushd .gh-pages
124+ git pull
124125fi
125126
126127if [ -n " $( git status --porcelain) " ]; then
127- echo " .gh-pages is not clean" >&2
128- exit 1
128+ echo " .gh-pages is not clean" >&2
129+ exit 1
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
158- echo " Aborting"
159- exit 1
159+ echo " Aborting"
160+ exit 1
160161fi
161162
162163git push
0 commit comments