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