Skip to content

Commit fd619e5

Browse files
committed
refactor(release): streamline whitespace handling in release script
- Added whitespace trimming for default branch and parameters in the release script to ensure cleaner input handling. - Updated GitHub Actions workflow to remove unnecessary escape characters for improved readability.
1 parent 7b8a6a9 commit fd619e5

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.github/scripts/release.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ determine_version_and_branch() {
6565
# Try to find the default branch, fallback to common branch names
6666
local default_branch
6767
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2> /dev/null | sed 's@^refs/remotes/origin/@@' || echo "")
68+
default_branch="$(trim_whitespace "$default_branch")"
6869

6970
if [ -z "$default_branch" ]; then
7071
# Try common branch names
@@ -75,6 +76,7 @@ determine_version_and_branch() {
7576
else
7677
# Fallback: use the first branch we find
7778
default_branch=$(git branch -r | grep -v HEAD | head -n1 | sed 's/origin\///' | xargs)
79+
default_branch="$(trim_whitespace "$default_branch")"
7880
fi
7981
fi
8082

@@ -158,8 +160,11 @@ bump_changelog_fixed() {
158160

159161
# Commit updated changelog
160162
commit_changelog() {
161-
local version="${1}"
162-
local branch="${2}"
163+
# Trim whitespace from parameters
164+
local version
165+
version="$(trim_whitespace "${1}")"
166+
local branch
167+
branch="$(trim_whitespace "${2}")"
163168

164169
if [ -n "$(git status --porcelain CHANGELOG.md)" ]; then
165170
git add CHANGELOG.md

.github/workflows/release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
fetch-depth: 0
3030
- name: Determine Version
3131
id: version
32-
run: ./.github/scripts/release.sh determine-version \ "${{ github.event_name }}"
33-
\ "${{ github.event.inputs.version }}"
32+
run: ./.github/scripts/release.sh determine-version "${{ github.event_name }}"
33+
"${{ github.event.inputs.version }}"
3434
wait:
3535
name: Wait for Tests
3636
runs-on: ubuntu-latest
@@ -61,12 +61,12 @@ jobs:
6161
run: ./.github/scripts/release.sh configure-git
6262
- name: Determine Version and Branch
6363
id: setup
64-
run: ./.github/scripts/release.sh determine-version-and-branch \ "${{ needs.validate.outputs.version }}"
64+
run: ./.github/scripts/release.sh determine-version-and-branch "${{ needs.validate.outputs.version }}"
6565
- name: Bump Changelog Version (Fixed)
6666
if: steps.setup.outputs.is_fixed_version == 'true'
6767
id: bump_fixed
68-
run: ./.github/scripts/release.sh bump-changelog-fixed \ "${{ steps.setup.outputs.version_no_v }}"
69-
\ "CHANGELOG.md" \ "true"
68+
run: ./.github/scripts/release.sh bump-changelog-fixed "${{ steps.setup.outputs.version_no_v }}"
69+
"CHANGELOG.md" "true"
7070
- name: Bump Changelog Version (Keyword)
7171
if: steps.setup.outputs.is_fixed_version != 'true'
7272
id: bump
@@ -78,8 +78,8 @@ jobs:
7878
tag-prefix: v
7979
keep-unreleased-section: true
8080
- name: Commit Updated Changelog
81-
run: ./.github/scripts/release.sh commit-changelog \ "${{ needs.validate.outputs.version }}"
82-
\ "${{ steps.setup.outputs.branch }}"
81+
run: ./.github/scripts/release.sh commit-changelog "${{ needs.validate.outputs.version }}"
82+
"${{ steps.setup.outputs.branch }}"
8383
- name: Query Release Notes
8484
id: query
8585
uses: release-flow/keep-a-changelog-action@74931dec7ecdbfc8e38ac9ae7e8dd84c08db2f32 # v3

0 commit comments

Comments
 (0)