@@ -10,6 +10,16 @@ if [ "$current_branch" = "main" ]; then
1010 exit 1
1111fi
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+
1323changelog=$( cat CHANGELOG.md)
1424
1525regex='
3646
3747tag=" v$version "
3848
49+ if [ -n " $( git status --porcelain) " ]; then
50+ echo " . is not clean." >&2
51+ exit 1
52+ fi
53+
3954rm -fr vendor
4055
4156perl -pi -e " s{(?<=php composer\.phar require maxmind-db/reader:).+}{^$version }g" README.md
@@ -70,6 +85,8 @@ echo "$notes"
7085
7186pecl package
7287
88+ package=" maxminddb-$version .tgz"
89+
7390read -p " Push to origin? (y/n) " should_push
7491
7592if [ " $should_push " != " y" ]; then
@@ -83,4 +100,157 @@ git push
83100
84101gh 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"
0 commit comments