Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/scripts/validate-and-generate-release-notes.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down