Skip to content

Commit bc6017e

Browse files
authored
Merge pull request #223 from maxmind/greg/eng-3504
Release to PIE
2 parents 62cdd95 + 2194f58 commit bc6017e

File tree

7 files changed

+219
-13
lines changed

7 files changed

+219
-13
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*.old
66
*.sublime-*
77
*.sw?
8+
.claude
89
.deps
10+
.ext
911
.gh-pages
1012
/.idea
1113
/.php-cs-fixer.cache

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
1.13.1 (2025-11-21)
5+
-------------------
6+
7+
* First PIE release. No other changes.
8+
49
1.13.0 (2025-11-20)
510
-------------------
611

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@
55
This is the PHP API for reading MaxMind DB files. MaxMind DB is a binary file
66
format that stores data indexed by IP address subnets (IPv4 or IPv6).
77

8-
## Installation (Composer) ##
8+
## Installation ##
99

10-
We recommend installing this package with [Composer](https://getcomposer.org/).
10+
### C Extension (Recommended for Performance) ###
11+
12+
For significantly faster IP lookups, we recommend installing the C extension via
13+
[PIE](https://github.com/php/pie):
14+
15+
```bash
16+
pie install maxmind-db/reader-ext
17+
```
18+
19+
The C extension requires the [libmaxminddb](https://github.com/maxmind/libmaxminddb)
20+
C library. See the [installation instructions](https://github.com/maxmind/MaxMind-DB-Reader-php-ext#prerequisites)
21+
for your platform.
22+
23+
### Pure PHP (No Compilation Required) ###
24+
25+
If you prefer not to compile a C extension or need maximum portability, you can
26+
install the pure PHP implementation with [Composer](https://getcomposer.org/).
1127

1228
### Download Composer ###
1329

@@ -24,7 +40,7 @@ You should now have the file `composer.phar` in your project directory.
2440
Run in your project root:
2541

2642
```
27-
php composer.phar require maxmind-db/reader:^1.13.0
43+
php composer.phar require maxmind-db/reader:^1.13.1
2844
```
2945

3046
You should now have the files `composer.json` and `composer.lock` as well as
@@ -108,18 +124,31 @@ MaxMind provides an optional C extension that is a drop-in replacement for
108124
Reader API as described above and install the extension as described below. If
109125
you are using an autoloader, no changes to your code should be necessary.
110126

111-
### Installing Extension ###
127+
### Installing Extension via PIE (Recommended) ###
128+
129+
We recommend installing the extension via [PIE](https://github.com/php/pie):
130+
131+
```bash
132+
pie install maxmind-db/reader-ext
133+
```
134+
135+
See the [extension repository](https://github.com/maxmind/MaxMind-DB-Reader-php-ext#prerequisites)
136+
for prerequisites including libmaxminddb installation instructions.
137+
138+
### Installing Extension via PECL (Legacy) ###
112139

113140
First install [libmaxminddb](https://github.com/maxmind/libmaxminddb) as
114141
described in its [README.md
115142
file](https://github.com/maxmind/libmaxminddb/blob/main/README.md#installing-from-a-tarball).
116143
After successfully installing libmaxmindb, you may install the extension
117-
from [pecl](https://pecl.php.net/package/maxminddb):
144+
from [PECL](https://pecl.php.net/package/maxminddb):
118145

119146
```
120147
pecl install maxminddb
121148
```
122149

150+
### Installing Extension from Source ###
151+
123152
Alternatively, you may install it from the source. To do so, run the following
124153
commands from the top-level directory of this distribution:
125154

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"suggest": {
1919
"ext-bcmath": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder",
2020
"ext-gmp": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder",
21-
"ext-maxminddb": "A C-based database decoder that provides significantly faster lookups"
21+
"ext-maxminddb": "A C-based database decoder that provides significantly faster lookups",
22+
"maxmind-db/reader-ext": "C extension for significantly faster IP lookups (install via PIE: pie install maxmind-db/reader-ext)"
2223
},
2324
"conflict": {
2425
"ext-maxminddb": "<1.11.1 || >=2.0.0"

dev-bin/release.sh

Lines changed: 171 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ if [ "$current_branch" = "main" ]; then
1010
exit 1
1111
fi
1212

13+
# Fetch latest changes and check that we're not behind origin/main
14+
echo "Fetching from origin..."
15+
git fetch origin
16+
17+
if ! git merge-base --is-ancestor origin/main HEAD; then
18+
echo "Error: Current branch is behind origin/main."
19+
echo "Please merge or rebase with origin/main before releasing."
20+
exit 1
21+
fi
22+
1323
changelog=$(cat CHANGELOG.md)
1424

1525
regex='
@@ -36,6 +46,11 @@ fi
3646

3747
tag="v$version"
3848

49+
if [ -n "$(git status --porcelain)" ]; then
50+
echo ". is not clean." >&2
51+
exit 1
52+
fi
53+
3954
rm -fr vendor
4055

4156
perl -pi -e "s{(?<=php composer\.phar require maxmind-db/reader:).+}{^$version}g" README.md
@@ -70,6 +85,8 @@ echo "$notes"
7085

7186
pecl package
7287

88+
package="maxminddb-$version.tgz"
89+
7390
read -p "Push to origin? (y/n) " should_push
7491

7592
if [ "$should_push" != "y" ]; then
@@ -83,4 +100,157 @@ git push
83100

84101
gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$tag"
85102

86-
echo "Upload PECL package to pecl.php.net!"
103+
# =============================================================================
104+
# EXTENSION REPOSITORY RELEASE AUTOMATION
105+
# =============================================================================
106+
107+
ext_repo_dir=".ext"
108+
ext_repo_url="[email protected]:maxmind/MaxMind-DB-Reader-php-ext.git"
109+
110+
echo ""
111+
echo "==================================================================="
112+
echo "UPDATING EXTENSION REPOSITORY"
113+
echo "==================================================================="
114+
115+
# Check if extension repository exists locally
116+
if [ ! -d "$ext_repo_dir" ]; then
117+
echo "Extension repository not found at: $ext_repo_dir"
118+
echo "Cloning extension repository..."
119+
git clone --recurse-submodules "$ext_repo_url" "$ext_repo_dir"
120+
121+
if [ $? -ne 0 ]; then
122+
echo "ERROR: Failed to clone extension repository"
123+
echo "Please clone manually: git clone --recurse-submodules $ext_repo_url $ext_repo_dir"
124+
exit 1
125+
fi
126+
fi
127+
128+
# Navigate to extension repository
129+
pushd "$ext_repo_dir" > /dev/null
130+
131+
# Safety check: ensure working directory is clean
132+
if [ -n "$(git status --porcelain)" ]; then
133+
echo "ERROR: Extension repository has uncommitted changes"
134+
echo "Please commit or stash changes in: $ext_repo_dir"
135+
popd > /dev/null
136+
exit 1
137+
fi
138+
139+
# Ensure we're on main branch
140+
current_branch=$(git rev-parse --abbrev-ref HEAD)
141+
if [ "$current_branch" != "main" ]; then
142+
echo "Switching to main branch..."
143+
git checkout main
144+
fi
145+
146+
# Pull latest changes
147+
echo "Pulling latest changes from origin..."
148+
git pull origin main
149+
150+
# Update submodule to the new tag
151+
echo "Updating submodule to $tag..."
152+
cd MaxMind-DB-Reader-php
153+
git fetch --tags origin
154+
git checkout "$tag"
155+
156+
if [ $? -ne 0 ]; then
157+
echo "ERROR: Failed to checkout tag $tag in submodule"
158+
popd > /dev/null
159+
exit 1
160+
fi
161+
162+
cd ..
163+
164+
# Stage submodule update
165+
git add MaxMind-DB-Reader-php
166+
167+
# Check if there are actual changes
168+
if [ -z "$(git status --porcelain)" ]; then
169+
echo "No changes needed in extension repository (already at $tag)"
170+
popd > /dev/null
171+
echo "Extension repository is up to date"
172+
else
173+
# Commit submodule update
174+
echo "Committing submodule update..."
175+
git commit -m "Update to MaxMind-DB-Reader-php $version
176+
177+
This updates the submodule reference to track the $tag release.
178+
179+
Release notes from main repository:
180+
$notes"
181+
182+
# Push changes
183+
echo "Pushing to origin..."
184+
git push origin main
185+
186+
if [ $? -ne 0 ]; then
187+
echo "ERROR: Failed to push to extension repository"
188+
popd > /dev/null
189+
exit 1
190+
fi
191+
192+
# Create pre-packaged source tarball for PIE
193+
# PIE needs this because it doesn't handle git submodules automatically
194+
echo "Creating pre-packaged source tarball for PIE..."
195+
pie_tarball="maxminddb-${tag}.tgz"
196+
197+
# Create tarball with files at root level (PIE requirement)
198+
# Note: naming must be {extension-name}-v{version}.tgz
199+
pushd MaxMind-DB-Reader-php/ext > /dev/null
200+
tar -czf "../../$pie_tarball" *
201+
popd > /dev/null
202+
203+
if [ ! -f "$pie_tarball" ]; then
204+
echo "ERROR: Failed to create source tarball"
205+
popd > /dev/null
206+
exit 1
207+
fi
208+
209+
echo "Created $pie_tarball"
210+
211+
# Create corresponding release in extension repo with same tag
212+
echo "Creating release $tag in extension repository..."
213+
gh release create "$tag" \
214+
--repo maxmind/MaxMind-DB-Reader-php-ext \
215+
--title "$version" \
216+
--notes "Extension release for MaxMind-DB-Reader-php $version
217+
218+
This release tracks the $tag tag of the main repository.
219+
220+
## Release notes from main repository
221+
222+
$notes" \
223+
"$pie_tarball"
224+
225+
if [ $? -ne 0 ]; then
226+
echo "ERROR: Failed to create release in extension repository"
227+
echo "You may need to create it manually at:"
228+
echo "https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/new?tag=$tag"
229+
popd > /dev/null
230+
exit 1
231+
fi
232+
233+
# Clean up tarball
234+
rm -f "$pie_tarball"
235+
236+
echo ""
237+
echo "✓ Extension repository updated successfully!"
238+
echo "✓ Release created: https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/tag/$tag"
239+
echo "✓ Pre-packaged source uploaded: $pie_tarball"
240+
fi
241+
242+
popd > /dev/null
243+
244+
echo ""
245+
echo "==================================================================="
246+
echo "RELEASE COMPLETE"
247+
echo "==================================================================="
248+
echo ""
249+
echo "Main repository: https://github.com/maxmind/MaxMind-DB-Reader-php/releases/tag/$tag"
250+
echo "Extension repository: https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/tag/$tag"
251+
echo ""
252+
echo "Action items:"
253+
echo "1. Upload PECL package to pecl.php.net: https://pecl.php.net/package-new.php"
254+
echo " File: $package"
255+
echo "2. Verify PIE installation: pie install maxmind-db/reader-ext:^$version"
256+
echo "3. Announce release"

ext/php_maxminddb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#ifndef PHP_MAXMINDDB_H
1717
#define PHP_MAXMINDDB_H 1
18-
#define PHP_MAXMINDDB_VERSION "1.13.0"
18+
#define PHP_MAXMINDDB_VERSION "1.13.1"
1919
#define PHP_MAXMINDDB_EXTNAME "maxminddb"
2020

2121
extern zend_module_entry maxminddb_module_entry;

package.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414
<email>[email protected]</email>
1515
<active>yes</active>
1616
</lead>
17-
<date>2025-11-20</date>
17+
<date>2025-11-21</date>
1818
<version>
19-
<release>1.13.0</release>
20-
<api>1.13.0</api>
19+
<release>1.13.1</release>
20+
<api>1.13.1</api>
2121
</version>
2222
<stability>
2323
<release>stable</release>
2424
<api>stable</api>
2525
</stability>
2626
<license uri="https://github.com/maxmind/MaxMind-DB-Reader-php/blob/main/LICENSE">Apache License 2.0</license>
27-
<notes>* A redundant `filesize()` call in the reader's constructor was removed.
28-
Pull request by Pavel Djundik. GitHub #189.</notes>
27+
<notes>* First PIE release. No other changes.</notes>
2928
<contents>
3029
<dir name="/">
3130
<file role="doc" name="LICENSE"/>

0 commit comments

Comments
 (0)