Skip to content

Commit 1fe6b63

Browse files
authored
Merge pull request #227 from maxmind/greg/eng-1733
Improve release script reliability (ENG-1733)
2 parents 985e277 + 7095078 commit 1fe6b63

File tree

2 files changed

+58
-25
lines changed

2 files changed

+58
-25
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ permissions: {}
1010

1111
jobs:
1212
run:
13-
runs-on: ${{ matrix.operating-system }}
13+
runs-on: ${{ matrix.runner }}
1414
container: shivammathur/node:latest-${{ matrix.arch }}
1515
strategy:
1616
matrix:
17-
arch: ["amd64", "i386"]
18-
operating-system: [ubuntu-latest]
17+
arch: ["amd64", "arm64v8"]
1918
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
2019
php-extension: ['bcmath', 'gmp']
21-
exclude:
22-
# We are getting weird libxml2 failures on this combo
23-
- arch: "i386"
24-
php-version: 8.4
20+
include:
21+
- arch: amd64
22+
runner: ubuntu-latest
23+
- arch: arm64v8
24+
runner: ubuntu-24.04-arm
2525

26-
name: "PHP ${{ matrix.php-version }} (with ${{ matrix.php-extension }}) test on ${{ matrix.operating-system }}/${{ matrix.arch }}"
26+
name: "PHP ${{ matrix.php-version }} (with ${{ matrix.php-extension }}) test on ${{ matrix.runner }}"
2727
steps:
2828
- name: Install PHP
2929
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0

dev-bin/release.sh

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,39 @@
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 php
35+
check_command phpize
36+
check_command pecl
37+
538
# Check that we're not on the main branch
639
current_branch=$(git branch --show-current)
740
if [ "$current_branch" = "main" ]; then
@@ -23,23 +56,23 @@ fi
2356
changelog=$(cat CHANGELOG.md)
2457

2558
regex='
26-
([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
59+
([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
2760
-*
2861
2962
((.|
3063
)*)
3164
'
3265

3366
if [[ ! $changelog =~ $regex ]]; then
34-
echo "Could not find date line in change log!"
35-
exit 1
67+
echo "Could not find date line in change log!"
68+
exit 1
3669
fi
3770

3871
version="${BASH_REMATCH[1]}"
39-
date="${BASH_REMATCH[2]}"
40-
notes="$(echo "${BASH_REMATCH[3]}" | sed -n -e '/^[0-9]\+\.[0-9]\+\.[0-9]\+/,$!p')"
72+
date="${BASH_REMATCH[3]}"
73+
notes="$(echo "${BASH_REMATCH[4]}" | sed -n -E '/^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?/,$!p')"
4174

42-
if [[ "$date" != $(date +"%Y-%m-%d") ]]; then
75+
if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then
4376
echo "$date is not today!"
4477
exit 1
4578
fi
@@ -87,7 +120,7 @@ pecl package
87120

88121
package="maxminddb-$version.tgz"
89122

90-
read -p "Push to origin? (y/n) " should_push
123+
read -r -p "Push to origin? (y/n) " should_push
91124

92125
if [ "$should_push" != "y" ]; then
93126
echo "Aborting"
@@ -126,13 +159,13 @@ if [ ! -d "$ext_repo_dir" ]; then
126159
fi
127160

128161
# Navigate to extension repository
129-
pushd "$ext_repo_dir" > /dev/null
162+
pushd "$ext_repo_dir" >/dev/null
130163

131164
# Safety check: ensure working directory is clean
132165
if [ -n "$(git status --porcelain)" ]; then
133166
echo "ERROR: Extension repository has uncommitted changes"
134167
echo "Please commit or stash changes in: $ext_repo_dir"
135-
popd > /dev/null
168+
popd >/dev/null
136169
exit 1
137170
fi
138171

@@ -155,7 +188,7 @@ git checkout "$tag"
155188

156189
if [ $? -ne 0 ]; then
157190
echo "ERROR: Failed to checkout tag $tag in submodule"
158-
popd > /dev/null
191+
popd >/dev/null
159192
exit 1
160193
fi
161194

@@ -167,7 +200,7 @@ git add MaxMind-DB-Reader-php
167200
# Check if there are actual changes
168201
if [ -z "$(git status --porcelain)" ]; then
169202
echo "No changes needed in extension repository (already at $tag)"
170-
popd > /dev/null
203+
popd >/dev/null
171204
echo "Extension repository is up to date"
172205
else
173206
# Commit submodule update
@@ -185,7 +218,7 @@ $notes"
185218

186219
if [ $? -ne 0 ]; then
187220
echo "ERROR: Failed to push to extension repository"
188-
popd > /dev/null
221+
popd >/dev/null
189222
exit 1
190223
fi
191224

@@ -196,13 +229,13 @@ $notes"
196229

197230
# Create tarball with files at root level (PIE requirement)
198231
# Note: naming must be {extension-name}-v{version}.tgz
199-
pushd MaxMind-DB-Reader-php/ext > /dev/null
232+
pushd MaxMind-DB-Reader-php/ext >/dev/null
200233
tar -czf "../../$pie_tarball" *
201-
popd > /dev/null
234+
popd >/dev/null
202235

203236
if [ ! -f "$pie_tarball" ]; then
204237
echo "ERROR: Failed to create source tarball"
205-
popd > /dev/null
238+
popd >/dev/null
206239
exit 1
207240
fi
208241

@@ -226,7 +259,7 @@ $notes" \
226259
echo "ERROR: Failed to create release in extension repository"
227260
echo "You may need to create it manually at:"
228261
echo "https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/new?tag=$tag"
229-
popd > /dev/null
262+
popd >/dev/null
230263
exit 1
231264
fi
232265

@@ -239,7 +272,7 @@ $notes" \
239272
echo "✓ Pre-packaged source uploaded: $pie_tarball"
240273
fi
241274

242-
popd > /dev/null
275+
popd >/dev/null
243276

244277
echo ""
245278
echo "==================================================================="

0 commit comments

Comments
 (0)