Skip to content

Commit 7b8a6a9

Browse files
committed
refactor(release): add whitespace trimming to version and changelog parameters
- Introduced a function to trim leading and trailing whitespace from version and changelog parameters in the release script. - Updated the bump_changelog_fixed function to utilize the new trimming functionality for improved parameter handling.
1 parent 9fcdde2 commit 7b8a6a9

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/scripts/release.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ set -euo pipefail
77
# shellcheck disable=SC2034
88
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
99

10+
# Trim leading and trailing whitespace from a string
11+
trim_whitespace() {
12+
local str="${1}"
13+
str="${str#"${str%%[![:space:]]*}"}" # trim leading whitespace
14+
str="${str%"${str##*[![:space:]]}"}" # trim trailing whitespace
15+
echo -n "$str"
16+
}
17+
1018
# Determine version from event or tag
1119
determine_version() {
1220
local event_name="${1}"
@@ -90,9 +98,13 @@ configure_git() {
9098
# This is used when we have a fixed version string (e.g., 0.1.0-rc.5)
9199
# instead of a version bump keyword (e.g., prerelease)
92100
bump_changelog_fixed() {
93-
local version="${1}"
94-
local changelog="${2:-CHANGELOG.md}"
95-
local keep_unreleased="${3:-false}"
101+
# Trim whitespace from parameters
102+
local version
103+
version="$(trim_whitespace "${1}")"
104+
local changelog
105+
changelog="$(trim_whitespace "${2:-CHANGELOG.md}")"
106+
local keep_unreleased
107+
keep_unreleased="$(trim_whitespace "${3:-false}")"
96108

97109
# Get current date in ISO 8601 format (YYYY-MM-DD)
98110
local release_date

0 commit comments

Comments
 (0)