@@ -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,54 +37,54 @@ check_command wget
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
5555phar=' geoip2.phar'
5656
5757changelog=$( cat CHANGELOG.md)
5858
5959regex='
60- ([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
60+ ([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)? ) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
6161-*
6262
6363((.|
6464)*)
6565'
6666
6767if [[ ! $changelog =~ $regex ]]; then
68- echo " Could not find date line in change log!"
69- exit 1
68+ echo " Could not find date line in change log!"
69+ exit 1
7070fi
7171
7272version=" ${BASH_REMATCH[1]} "
73- date=" ${BASH_REMATCH[2 ]} "
74- notes=" $( echo " ${BASH_REMATCH[3 ]} " | sed -n -e ' /^[0-9]\ +\.[0-9]\ +\.[0-9]\+ /,$!p' ) "
73+ date=" ${BASH_REMATCH[3 ]} "
74+ notes=" $( echo " ${BASH_REMATCH[4 ]} " | sed -n -E ' /^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)? /,$!p' ) "
7575
76- if [[ " $date " != $( date +" %Y-%m-%d" ) ]]; then
77- echo " $date is not today!"
78- exit 1
76+ if [[ " $date " != " $( date +" %Y-%m-%d" ) " ]]; then
77+ echo " $date is not today!"
78+ exit 1
7979fi
8080
8181tag=" v$version "
8282
8383rm -f " $phar "
8484
8585if [ -n " $( git status --porcelain) " ]; then
86- echo " . is not clean." >&2
87- exit 1
86+ echo " . is not clean." >&2
87+ exit 1
8888fi
8989
9090rm -fr vendor
@@ -95,11 +95,10 @@ php composer.phar update --no-dev
9595perl -pi -e " s/(?<=const VERSION = ').+?(?=';)/$tag /g" src/WebService/Client.php
9696perl -pi -e " s{(?<=php composer\.phar require geoip2/geoip2:).+}{^$version }g" README.md
9797
98-
9998box_phar_hash=' f98cf885a7c07c84df66e33888f1d93f063298598e0a5f41ca322aeb9683179b box.phar'
10099
101100if ! echo " $box_phar_hash " | sha256sum -c; then
102- wget -O box.phar " https://github.com/box-project/box/releases/download/4.6.10/box.phar"
101+ wget -O box.phar " https://github.com/box-project/box/releases/download/4.6.10/box.phar"
103102fi
104103
105104echo " $box_phar_hash " | sha256sum -c
@@ -108,8 +107,8 @@ php box.phar compile
108107
109108phar_test=$( ./dev-bin/phar-test.php)
110109if [[ -n $phar_test ]]; then
111- echo " Phar test outputed non-empty string: $phar_test "
112- exit 1
110+ echo " Phar test outputed non-empty string: $phar_test "
111+ exit 1
113112fi
114113
115114# Download test deps
@@ -118,36 +117,35 @@ php composer.phar update
118117./vendor/bin/phpunit
119118
120119if [ ! -d .gh-pages ]; then
121- echo " Checking out gh-pages in .gh-pages"
122- git clone -b gh-pages
[email protected] :maxmind/GeoIP2-php.git .gh-pages
123- pushd .gh-pages
120+ echo " Checking out gh-pages in .gh-pages"
121+ git clone -b gh-pages
[email protected] :maxmind/GeoIP2-php.git .gh-pages
122+ pushd .gh-pages
124123else
125- echo " Updating .gh-pages"
126- pushd .gh-pages
127- git pull
124+ echo " Updating .gh-pages"
125+ pushd .gh-pages
126+ git pull
128127fi
129128
130129if [ ! -d .maxminddb ]; then
131- echo " Cloning MaxMind-DB for docs"
132- git clone
[email protected] :maxmind/MaxMind-DB-Reader-php.git .maxminddb
130+ echo " Cloning MaxMind-DB for docs"
131+ git clone
[email protected] :maxmind/MaxMind-DB-Reader-php.git .maxminddb
133132else
134- echo " Updating MaxMind-DB for docs"
135- pushd .maxminddb
136- git pull
137- popd
133+ echo " Updating MaxMind-DB for docs"
134+ pushd .maxminddb
135+ git pull
136+ popd
138137fi
139138
140-
141139if [ -n " $( git status --porcelain) " ]; then
142- echo " .gh-pages is not clean" >&2
143- exit 1
140+ echo " .gh-pages is not clean" >&2
141+ exit 1
144142fi
145143
146144# Using Composer is possible, but they don't recommend it.
147145phpdocumentor_phar_hash=' aa00973d88b278fe59fd8dce826d8d5419df589cb7563ac379856ec305d6b938 phpDocumentor.phar'
148146
149147if ! echo " $phpdocumentor_phar_hash " | sha256sum -c; then
150- wget -O phpDocumentor.phar https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.8.1/phpDocumentor.phar
148+ wget -O phpDocumentor.phar https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.8.1/phpDocumentor.phar
151149fi
152150
153151echo " $phpdocumentor_phar_hash " | sha256sum -c
@@ -157,12 +155,12 @@ cachedir="/tmp/phpdoc-$$-$RANDOM"
157155rm -rf " $cachedir "
158156
159157php phpDocumentor.phar \
160- --visibility=public \
161- --cache-folder=" $cachedir " \
162- --title=" GeoIP2 PHP API $tag " \
163- run \
164- -d " $PWD /../src" \
165- -t " doc/$tag "
158+ --visibility=public \
159+ --cache-folder=" $cachedir " \
160+ --title=" GeoIP2 PHP API $tag " \
161+ run \
162+ -d " $PWD /../src" \
163+ -t " doc/$tag "
166164# This used to work but doesn't as of 4.5.1. They say that they are working
167165# on fixing it. Neither the config file nor the relative path fix work as
168166# suggested either.
@@ -171,7 +169,7 @@ php phpDocumentor.phar \
171169rm -rf " $cachedir "
172170
173171page=index.md
174- cat << EOF > $page
172+ cat << EOF >$page
175173---
176174layout: default
177175title: MaxMind GeoIP2 PHP API
@@ -181,18 +179,18 @@ version: $tag
181179
182180EOF
183181
184- cat ../README.md >> $page
182+ cat ../README.md >> $page
185183
186184git add doc/
187185
188186echo " Release notes for $tag :"
189187echo " $notes "
190188
191- read -e -p " Commit changes and push to origin? " should_push
189+ read -r - e -p " Commit changes and push to origin? " should_push
192190
193191if [ " $should_push " != " y" ]; then
194- echo " Aborting"
195- exit 1
192+ echo " Aborting"
193+ exit 1
196194fi
197195
198196git commit -m " Updated for $tag " -a
@@ -205,5 +203,3 @@ git commit -m "Update for $tag" -a
205203git push
206204
207205gh release create --target " $( git branch --show-current) " -t " $version " -n " $notes " " $tag " " $phar "
208-
209- git push --tags
0 commit comments