From 837668ba516b5d86c45be858292a6a2fdec949b4 Mon Sep 17 00:00:00 2001 From: widal001 Date: Tue, 16 Dec 2025 09:24:18 -0500 Subject: [PATCH] ci: Fixes script to generate release notes The script failed if it received `--previous-tag ""` as an option because the script only ignored the previous tag if it was omitted or received no argument. This updates the option parsing to also skip the previous tag if it receives an empty string `""` --- .../validate-and-generate-release-notes.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/scripts/validate-and-generate-release-notes.sh b/.github/scripts/validate-and-generate-release-notes.sh index 08f7050f..aa1283ac 100755 --- a/.github/scripts/validate-and-generate-release-notes.sh +++ b/.github/scripts/validate-and-generate-release-notes.sh @@ -1,6 +1,13 @@ #!/bin/bash # Script to validate tags and generate release notes -# Usage: validate-and-generate-release-notes.sh --prefix PREFIX --config-file CONFIG --release-tag TAG [--previous-tag PREV_TAG] [--dry-run] [--repository REPO] [--github-output OUTPUT_FILE] +# Usage: validate-and-generate-release-notes.sh \ +# --prefix PREFIX \ +# --config-file CONFIG \ +# --release-tag TAG \ +# [--previous-tag PREV_TAG] \ +# [--dry-run] \ +# [--repository REPO] \ +# [--github-output OUTPUT_FILE] set -e @@ -28,8 +35,13 @@ while [[ $# -gt 0 ]]; do shift 2 ;; --previous-tag) - # Checks if the next argument ($2) exists and is not another option (does not start with --) - if [[ -n "$2" ]] && [[ ! "$2" =~ ^-- ]]; then + # Optional argument: accepts a value if the next argument exists and isn't another flag + # Handles these scenarios: + # --previous-tag "v1.0.0" → PREVIOUS_TAG="v1.0.0", shift 2 + # --previous-tag "" → PREVIOUS_TAG="", shift 2 (explicit empty string) + # --previous-tag --other-flag → PREVIOUS_TAG unchanged, shift 1 (next arg is a flag) + # --previous-tag (at end) → PREVIOUS_TAG unchanged, shift 1 (no more args) + if [[ $# -gt 1 ]] && [[ ! "$2" =~ ^-- ]]; then PREVIOUS_TAG="$2" shift 2 else