@@ -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
1616if ! gh auth status & > /dev/null; then
17- echo " Error: gh CLI is not authenticated. Run 'gh auth login' first."
18- exit 1
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
2222if ! 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
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.)
2828if ! git ls-remote origin & > /dev/null; then
29- echo " Error: Cannot connect to git remote. Check your git credentials/SSH keys."
30- exit 1
29+ echo " Error: Cannot connect to git remote. Check your git credentials/SSH keys."
30+ exit 1
3131fi
3232
3333check_command perl
@@ -38,19 +38,19 @@ check_command pecl
3838# Check that we're not on the main branch
3939current_branch=$( git branch --show-current)
4040if [ " $current_branch " = " main" ]; then
41- echo " Error: Releases should not be done directly on the main branch."
42- echo " Please create a release branch and run this script from there."
43- exit 1
41+ echo " Error: Releases should not be done directly on the main branch."
42+ echo " Please create a release branch and run this script from there."
43+ exit 1
4444fi
4545
4646# Fetch latest changes and check that we're not behind origin/main
4747echo " Fetching from origin..."
4848git fetch origin
4949
5050if ! git merge-base --is-ancestor origin/main HEAD; then
51- echo " Error: Current branch is behind origin/main."
52- echo " Please merge or rebase with origin/main before releasing."
53- exit 1
51+ echo " Error: Current branch is behind origin/main."
52+ echo " Please merge or rebase with origin/main before releasing."
53+ exit 1
5454fi
5555
5656changelog=$( cat CHANGELOG.md)
@@ -64,24 +64,24 @@ regex='
6464'
6565
6666if [[ ! $changelog =~ $regex ]]; then
67- echo " Could not find date line in change log!"
68- exit 1
67+ echo " Could not find date line in change log!"
68+ exit 1
6969fi
7070
7171version=" ${BASH_REMATCH[1]} "
7272date=" ${BASH_REMATCH[3]} "
7373notes=" $( echo " ${BASH_REMATCH[4]} " | sed -n -E ' /^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?/,$!p' ) "
7474
7575if [[ " $date " != " $( date +" %Y-%m-%d" ) " ]]; then
76- echo " $date is not today!"
77- exit 1
76+ echo " $date is not today!"
77+ exit 1
7878fi
7979
8080tag=" v$version "
8181
8282if [ -n " $( git status --porcelain) " ]; then
83- echo " . is not clean." >&2
84- exit 1
83+ echo " . is not clean." >&2
84+ exit 1
8585fi
8686
8787rm -fr vendor
@@ -110,7 +110,7 @@ echo $'\nDiff:'
110110git diff
111111
112112if [ -n " $( git status --porcelain) " ]; then
113- git commit -m " Bumped version to $version " -a
113+ git commit -m " Bumped version to $version " -a
114114fi
115115
116116echo $' \n Release notes:'
@@ -123,8 +123,8 @@ package="maxminddb-$version.tgz"
123123read -r -p " Push to origin? (y/n) " should_push
124124
125125if [ " $should_push " != " y" ]; then
126- echo " Aborting"
127- exit 1
126+ echo " Aborting"
127+ exit 1
128128fi
129129
130130echo " Creating tag $tag "
@@ -147,33 +147,33 @@ echo "==================================================================="
147147
148148# Check if extension repository exists locally
149149if [ ! -d " $ext_repo_dir " ]; then
150- echo " Extension repository not found at: $ext_repo_dir "
151- echo " Cloning extension repository..."
152- git clone --recurse-submodules " $ext_repo_url " " $ext_repo_dir "
153-
154- if [ $? -ne 0 ]; then
155- echo " ERROR: Failed to clone extension repository"
156- echo " Please clone manually: git clone --recurse-submodules $ext_repo_url $ext_repo_dir "
157- exit 1
158- fi
150+ echo " Extension repository not found at: $ext_repo_dir "
151+ echo " Cloning extension repository..."
152+ git clone --recurse-submodules " $ext_repo_url " " $ext_repo_dir "
153+
154+ if [ $? -ne 0 ]; then
155+ echo " ERROR: Failed to clone extension repository"
156+ echo " Please clone manually: git clone --recurse-submodules $ext_repo_url $ext_repo_dir "
157+ exit 1
158+ fi
159159fi
160160
161161# Navigate to extension repository
162162pushd " $ext_repo_dir " > /dev/null
163163
164164# Safety check: ensure working directory is clean
165165if [ -n " $( git status --porcelain) " ]; then
166- echo " ERROR: Extension repository has uncommitted changes"
167- echo " Please commit or stash changes in: $ext_repo_dir "
168- popd > /dev/null
169- exit 1
166+ echo " ERROR: Extension repository has uncommitted changes"
167+ echo " Please commit or stash changes in: $ext_repo_dir "
168+ popd > /dev/null
169+ exit 1
170170fi
171171
172172# Ensure we're on main branch
173173current_branch=$( git rev-parse --abbrev-ref HEAD)
174174if [ " $current_branch " != " main" ]; then
175- echo " Switching to main branch..."
176- git checkout main
175+ echo " Switching to main branch..."
176+ git checkout main
177177fi
178178
179179# Pull latest changes
@@ -187,9 +187,9 @@ git fetch --tags origin
187187git checkout " $tag "
188188
189189if [ $? -ne 0 ]; then
190- echo " ERROR: Failed to checkout tag $tag in submodule"
191- popd > /dev/null
192- exit 1
190+ echo " ERROR: Failed to checkout tag $tag in submodule"
191+ popd > /dev/null
192+ exit 1
193193fi
194194
195195cd ..
@@ -199,77 +199,77 @@ git add MaxMind-DB-Reader-php
199199
200200# Check if there are actual changes
201201if [ -z " $( git status --porcelain) " ]; then
202- echo " No changes needed in extension repository (already at $tag )"
203- popd > /dev/null
204- echo " Extension repository is up to date"
202+ echo " No changes needed in extension repository (already at $tag )"
203+ popd > /dev/null
204+ echo " Extension repository is up to date"
205205else
206- # Commit submodule update
207- echo " Committing submodule update..."
208- git commit -m " Update to MaxMind-DB-Reader-php $version
206+ # Commit submodule update
207+ echo " Committing submodule update..."
208+ git commit -m " Update to MaxMind-DB-Reader-php $version
209209
210210This updates the submodule reference to track the $tag release.
211211
212212Release notes from main repository:
213213$notes "
214214
215- # Push changes
216- echo " Pushing to origin..."
217- git push origin main
218-
219- if [ $? -ne 0 ]; then
220- echo " ERROR: Failed to push to extension repository"
221- popd > /dev/null
222- exit 1
223- fi
224-
225- # Create pre-packaged source tarball for PIE
226- # PIE needs this because it doesn't handle git submodules automatically
227- echo " Creating pre-packaged source tarball for PIE..."
228- pie_tarball=" maxminddb-${tag} .tgz"
229-
230- # Create tarball with files at root level (PIE requirement)
231- # Note: naming must be {extension-name}-v{version}.tgz
232- pushd MaxMind-DB-Reader-php/ext > /dev/null
233- tar -czf " ../../$pie_tarball " *
234- popd > /dev/null
235-
236- if [ ! -f " $pie_tarball " ]; then
237- echo " ERROR: Failed to create source tarball"
238- popd > /dev/null
239- exit 1
240- fi
241-
242- echo " Created $pie_tarball "
243-
244- # Create corresponding release in extension repo with same tag
245- echo " Creating release $tag in extension repository..."
246- gh release create " $tag " \
247- --repo maxmind/MaxMind-DB-Reader-php-ext \
248- --title " $version " \
249- --notes " Extension release for MaxMind-DB-Reader-php $version
215+ # Push changes
216+ echo " Pushing to origin..."
217+ git push origin main
218+
219+ if [ $? -ne 0 ]; then
220+ echo " ERROR: Failed to push to extension repository"
221+ popd > /dev/null
222+ exit 1
223+ fi
224+
225+ # Create pre-packaged source tarball for PIE
226+ # PIE needs this because it doesn't handle git submodules automatically
227+ echo " Creating pre-packaged source tarball for PIE..."
228+ pie_tarball=" maxminddb-${tag} .tgz"
229+
230+ # Create tarball with files at root level (PIE requirement)
231+ # Note: naming must be {extension-name}-v{version}.tgz
232+ pushd MaxMind-DB-Reader-php/ext > /dev/null
233+ tar -czf " ../../$pie_tarball " *
234+ popd > /dev/null
235+
236+ if [ ! -f " $pie_tarball " ]; then
237+ echo " ERROR: Failed to create source tarball"
238+ popd > /dev/null
239+ exit 1
240+ fi
241+
242+ echo " Created $pie_tarball "
243+
244+ # Create corresponding release in extension repo with same tag
245+ echo " Creating release $tag in extension repository..."
246+ gh release create " $tag " \
247+ --repo maxmind/MaxMind-DB-Reader-php-ext \
248+ --title " $version " \
249+ --notes " Extension release for MaxMind-DB-Reader-php $version
250250
251251This release tracks the $tag tag of the main repository.
252252
253253## Release notes from main repository
254254
255255$notes " \
256- " $pie_tarball "
257-
258- if [ $? -ne 0 ]; then
259- echo " ERROR: Failed to create release in extension repository"
260- echo " You may need to create it manually at:"
261- echo " https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/new?tag=$tag "
262- popd > /dev/null
263- exit 1
264- fi
265-
266- # Clean up tarball
267- rm -f " $pie_tarball "
268-
269- echo " "
270- echo " ✓ Extension repository updated successfully!"
271- echo " ✓ Release created: https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/tag/$tag "
272- echo " ✓ Pre-packaged source uploaded: $pie_tarball "
256+ " $pie_tarball "
257+
258+ if [ $? -ne 0 ]; then
259+ echo " ERROR: Failed to create release in extension repository"
260+ echo " You may need to create it manually at:"
261+ echo " https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/new?tag=$tag "
262+ popd > /dev/null
263+ exit 1
264+ fi
265+
266+ # Clean up tarball
267+ rm -f " $pie_tarball "
268+
269+ echo " "
270+ echo " ✓ Extension repository updated successfully!"
271+ echo " ✓ Release created: https://github.com/maxmind/MaxMind-DB-Reader-php-ext/releases/tag/$tag "
272+ echo " ✓ Pre-packaged source uploaded: $pie_tarball "
273273fi
274274
275275popd > /dev/null
0 commit comments