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 rake
35+
536# Check that we're not on the main branch
637current_branch=$( git branch --show-current)
738if [ " $current_branch " = " main" ]; then
2354changelog=$( cat CHANGELOG.md)
2455
2556regex='
26- ## ([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
57+ ## ([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)? ) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
2758
2859((.|
2960)*)
3061'
3162
3263if [[ ! $changelog =~ $regex ]]; then
33- echo " Could not find date line in change log!"
34- exit 1
64+ echo " Could not find date line in change log!"
65+ exit 1
3566fi
3667
3768version=" ${BASH_REMATCH[1]} "
38- date=" ${BASH_REMATCH[2 ]} "
39- notes=" $( echo " ${BASH_REMATCH[3 ]} " | sed -n -E ' /^## [0-9]+\.[0-9]+\.[0-9]+/,$!p' ) "
69+ date=" ${BASH_REMATCH[3 ]} "
70+ notes=" $( echo " ${BASH_REMATCH[4 ]} " | sed -n -E ' /^## [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)? /,$!p' ) "
4071
4172echo " $notes "
4273if [[ " $date " != " $( date +" %Y-%m-%d" ) " ]]; then
@@ -63,7 +94,7 @@ git diff
6394echo $' \n Release notes:'
6495echo " $notes "
6596
66- read -e -p " Commit changes and push to origin? " should_push
97+ read -r - e -p " Commit changes and push to origin? " should_push
6798
6899if [ " $should_push " != " y" ]; then
69100 echo " Aborting"
0 commit comments