1- #! /bin/bash
1+ #! /usr/ bin/env bash
22
33# Prompt for the version number
44prompt_for_version () {
@@ -8,19 +8,26 @@ prompt_for_version() {
88
99# Increment version number
1010increment_version () {
11- local IFS=' .'
12- read -ar version_parts <<< " $1"
13- # Increment the minor version and reset patch version
11+ # Split the version string into parts using read -a
12+ IFS=' .'
13+ read -ra version_parts <<< " $1"
14+
15+ # Ensure that we have exactly three parts for major, minor, and patch versions
16+ if [ ${# version_parts[@]} -ne 3 ]; then
17+ echo " Error: Invalid version format '$1 '. Expected format 'Major.Minor.Patch'." >&2
18+ return 1 # Exit the function with an error status
19+ fi
20+
21+ # Increment the minor version and reset the patch version to 0
1422 local next_version=" ${version_parts[0]} .$(( version_parts[1 ] + 1 )) .0"
1523
16- # Prompt for the version number, using the next version as the default
17- read -rp " Enter the version number (default: $next_version ): " version
18- echo " ${version:- $next_version } " # Return the entered version number or the default if none was entered
24+ # Call prompt_for_version, using the next version as the default
25+ prompt_for_version " $next_version "
1926}
2027
2128# Get the latest version tag
2229get_latest_version () {
23- git describe --tags " $( git rev-list --tags --max-count=1) "
30+ git describe --tags " $( git rev-list --tags --max-count=1) " 2> /dev/null || echo " v0.0.0 "
2431}
2532
2633# Prepend the tickets to the CHANGELOG.md
0 commit comments