Add date normalization script for release pipeline #40

Merged
Copilot merged 5 commits from copilot/add-date-normalization-script into main 2026-01-09 01:27:22 +00:00
Showing only changes of commit 1ee2b16c7b - Show all commits

View File

@@ -31,15 +31,24 @@ set -euo pipefail
TODAY="${1:-$(date +%Y-%m-%d)}" TODAY="${1:-$(date +%Y-%m-%d)}"
VERSION="${2:-unknown}" VERSION="${2:-unknown}"
copilot-pull-request-reviewer[bot] commented 2026-01-09 01:34:16 +00:00 (Migrated from github.com)
Review

The VERSION parameter defaults to "unknown" but lacks validation when explicitly provided. If an empty string or whitespace-only value is passed as the second argument, it could lead to incorrect sed patterns that match unintended lines. Consider adding validation to ensure VERSION is not empty and contains expected characters, similar to the date validation on line 35.

The VERSION parameter defaults to "unknown" but lacks validation when explicitly provided. If an empty string or whitespace-only value is passed as the second argument, it could lead to incorrect sed patterns that match unintended lines. Consider adding validation to ensure VERSION is not empty and contains expected characters, similar to the date validation on line 35.
# Validate date format (YYYY-MM-DD)
if ! [[ "${TODAY}" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format '${TODAY}'. Expected YYYY-MM-DD format."
exit 1
fi
echo "Date normalization script running..." echo "Date normalization script running..."
echo "TODAY: ${TODAY}" echo "TODAY: ${TODAY}"
echo "VERSION: ${VERSION}" echo "VERSION: ${VERSION}"
# Escape special regex characters in VERSION for safe use in grep and sed
VERSION_ESCAPED=$(printf '%s\n' "${VERSION}" | sed 's/[]\/$*.^[]/\\&/g')
# Update CHANGELOG.md - replace the date on the version heading line # Update CHANGELOG.md - replace the date on the version heading line
if [ -f "CHANGELOG.md" ]; then if [ -f "CHANGELOG.md" ]; then
# Match lines like "## [03.05.00] 2026-01-04" and update the date # Match lines like "## [03.05.00] 2026-01-04" and update the date
if grep -q "^## \[${VERSION}\] " CHANGELOG.md; then if grep -q "^## \[${VERSION_ESCAPED}\] " CHANGELOG.md; then
sed -i "s/^## \[${VERSION}\] [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/## [${VERSION}] ${TODAY}/" CHANGELOG.md sed -i "s/^## \[${VERSION_ESCAPED}\] [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/## [${VERSION_ESCAPED}] ${TODAY}/" CHANGELOG.md
echo "✓ Updated CHANGELOG.md version [${VERSION}] date to ${TODAY}" echo "✓ Updated CHANGELOG.md version [${VERSION}] date to ${TODAY}"
else else
echo "⚠ Warning: CHANGELOG.md does not contain version [${VERSION}] heading" echo "⚠ Warning: CHANGELOG.md does not contain version [${VERSION}] heading"