22
33set -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 wget
36+
537# Check that we're not on the main branch
638current_branch=$( git branch --show-current)
739if [ " $current_branch " = " main" ]; then
@@ -33,15 +65,15 @@ regex='
3365'
3466
3567if [[ ! $changelog =~ $regex ]]; then
36- echo " Could not find date line in change log!"
37- exit 1
68+ echo " Could not find date line in change log!"
69+ exit 1
3870fi
3971
4072version=" ${BASH_REMATCH[1]} "
4173date=" ${BASH_REMATCH[3]} "
42- notes=" $( echo " ${BASH_REMATCH[4]} " | sed -n -E ' /^[0-9]+\.[0-9]+\.[0-9]+/,$!p' ) "
74+ notes=" $( echo " ${BASH_REMATCH[4]} " | sed -n -E ' /^[0-9]+\.[0-9]+\.[0-9]+(-[^ ]+)? /,$!p' ) "
4375
44- if [[ " $date " != $( date +" %Y-%m-%d" ) ]]; then
76+ if [[ " $date " != " $( date +" %Y-%m-%d" ) " ]]; then
4577 echo " $date is not today!"
4678 exit 1
4779fi
106138 popd
107139fi
108140
109-
110141if [ -n " $( git status --porcelain) " ]; then
111142 echo " .gh-pages is not clean" >&2
112143 exit 1
@@ -140,7 +171,7 @@ php phpDocumentor.phar \
140171rm -rf " $cachedir "
141172
142173page=index.md
143- cat << EOF > $page
174+ cat << EOF >$page
144175---
145176layout: default
146177title: minFraud PHP API
@@ -150,14 +181,14 @@ version: $tag
150181
151182EOF
152183
153- cat ../README.md >> $page
184+ cat ../README.md >> $page
154185
155186git add doc/
156187
157188echo " Release notes for $tag :"
158189echo " $notes "
159190
160- read -e -p " Commit changes and push to origin? " should_push
191+ read -r - e -p " Commit changes and push to origin? " should_push
161192
162193if [ " $should_push " != " y" ]; then
163194 echo " Aborting"
@@ -174,5 +205,3 @@ git commit -m "Update for $tag" -a
174205git push
175206
176207gh release create --target " $( git branch --show-current) " -t " $version " -n " $notes " " $tag " " $phar "
177-
178- git push --tags
0 commit comments