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
Copilot commented 2026-01-09 01:15:49 +00:00 (Migrated from github.com)

Pull Request

Purpose

The release pipeline failed because the required date normalization script scripts/release/update_dates.sh was missing. The workflow checks for this script in approved locations and exits if not found.

Change Summary

  • Added scripts/release/update_dates.sh: Normalizes release dates across three files during the release process

    • CHANGELOG.md: Updates version heading dates (e.g., ## [03.05.00] 2026-01-09)
    • src/templates/templateDetails.xml: Updates <creationDate> XML tag
    • updates.xml: Updates <creationDate> XML tag
  • Script features:

    • Accepts DATE (YYYY-MM-DD) and VERSION as arguments, defaults to current date
    • Validates date format before processing
    • Escapes regex special characters in version strings for safe sed/grep operations
    • Uses set -euo pipefail for robust error handling
#!/usr/bin/env bash
set -euo pipefail

TODAY="${1:-$(date +%Y-%m-%d)}"
VERSION="${2:-unknown}"

# Validate date format
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

# Escape special regex chars in VERSION
VERSION_ESCAPED=$(printf '%s\n' "${VERSION}" | sed 's/[][\/$*.^]/\\&/g')

Testing Evidence

Script tested with valid and invalid inputs:

  • Successfully updates all three target files with version 03.05.00
  • Rejects malformed dates (e.g., 01/09/2026)
  • Handles version strings with special characters via regex escaping

Risk and Rollback

Risk: Low. Script is additive and only runs during manual workflow dispatch.

Rollback: Remove script or workflow will fail fast at validation step.

Checklist

  • Follows Conventional Commits
  • Tests added or updated (no test infrastructure for shell scripts)
  • Documentation updated if required (workflow reference is sufficient)
  • License header present where applicable
  • Linked issue(s) referenced

Reviewer Notes

The workflow expects this script at one of three locations (in priority order):

  1. scripts/release/update_dates.sh ✓ (implemented)
  2. scripts/release/update_dates
  3. scripts/update_dates.sh

Review and Approval

Original prompt

The job failed because the required date normalization script, scripts/release/update_dates.sh, is missing from the repository. The workflow step clearly checks for this script and exits with an error if it cannot be found in approved locations.

To resolve the failure:

  1. Add the script scripts/release/update_dates.sh to your repository (this is the preferred location, as required by the workflow).
  2. Make sure the script is executable:
    chmod +x scripts/release/update_dates.sh
    
  3. Commit and push the script to the branch.

If you do not have the script yet, you need to create it. The purpose of this script is typically to update or normalize date information in your source files during the release process. Here is a basic template you could adapt:

#!/usr/bin/env bash
set -euo pipefail
TODAY="${1:-$(date +%Y-%m-%d)}"
VERSION="${2:-unknown}"

# Example: update a metadata file
sed -i "s/^Date: .*/Date: ${TODAY}/" CHANGELOG.md
sed -i "s/^Version: .*/Version: ${VERSION}/" CHANGELOG.md

# Add your custom logic here for other files as needed

After adding and pushing the script, re-run your workflow. This should resolve the failure for the date normalization step.

You can view the workflow definition for this requirement in your release pipeline:
.github/workflows/release_pipeline.yml at 8fef274


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

# Pull Request ## Purpose The release pipeline failed because the required date normalization script `scripts/release/update_dates.sh` was missing. The workflow checks for this script in approved locations and exits if not found. ## Change Summary - **Added `scripts/release/update_dates.sh`**: Normalizes release dates across three files during the release process - `CHANGELOG.md`: Updates version heading dates (e.g., `## [03.05.00] 2026-01-09`) - `src/templates/templateDetails.xml`: Updates `<creationDate>` XML tag - `updates.xml`: Updates `<creationDate>` XML tag - **Script features**: - Accepts `DATE` (YYYY-MM-DD) and `VERSION` as arguments, defaults to current date - Validates date format before processing - Escapes regex special characters in version strings for safe sed/grep operations - Uses `set -euo pipefail` for robust error handling ```bash #!/usr/bin/env bash set -euo pipefail TODAY="${1:-$(date +%Y-%m-%d)}" VERSION="${2:-unknown}" # Validate date format 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 # Escape special regex chars in VERSION VERSION_ESCAPED=$(printf '%s\n' "${VERSION}" | sed 's/[][\/$*.^]/\\&/g') ``` ## Testing Evidence Script tested with valid and invalid inputs: - Successfully updates all three target files with version `03.05.00` - Rejects malformed dates (e.g., `01/09/2026`) - Handles version strings with special characters via regex escaping ## Risk and Rollback **Risk**: Low. Script is additive and only runs during manual workflow dispatch. **Rollback**: Remove script or workflow will fail fast at validation step. ## Checklist - [x] Follows Conventional Commits - [ ] Tests added or updated (no test infrastructure for shell scripts) - [ ] Documentation updated if required (workflow reference is sufficient) - [x] License header present where applicable - [x] Linked issue(s) referenced ## Reviewer Notes The workflow expects this script at one of three locations (in priority order): 1. `scripts/release/update_dates.sh` ✓ (implemented) 2. `scripts/release/update_dates` 3. `scripts/update_dates.sh` ## Review and Approval <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > The job failed because the required date normalization script, scripts/release/update_dates.sh, is missing from the repository. The workflow step clearly checks for this script and exits with an error if it cannot be found in approved locations. > > To resolve the failure: > > 1. Add the script scripts/release/update_dates.sh to your repository (this is the preferred location, as required by the workflow). > 2. Make sure the script is executable: > ```bash > chmod +x scripts/release/update_dates.sh > ``` > 3. Commit and push the script to the branch. > > If you do not have the script yet, you need to create it. The purpose of this script is typically to update or normalize date information in your source files during the release process. Here is a basic template you could adapt: > > ```bash > #!/usr/bin/env bash > set -euo pipefail > TODAY="${1:-$(date +%Y-%m-%d)}" > VERSION="${2:-unknown}" > > # Example: update a metadata file > sed -i "s/^Date: .*/Date: ${TODAY}/" CHANGELOG.md > sed -i "s/^Version: .*/Version: ${VERSION}/" CHANGELOG.md > > # Add your custom logic here for other files as needed > ``` > > After adding and pushing the script, re-run your workflow. This should resolve the failure for the date normalization step. > > You can view the workflow definition for this requirement in your release pipeline: > [.github/workflows/release_pipeline.yml at 8fef274](https://github.com/mokoconsulting-tech/moko-cassiopeia/blob/8fef2745a4e41370eb467fbea57622f40baad55e/.github/workflows/release_pipeline.yml) </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
jmiller-moko (Migrated from github.com) reviewed 2026-01-09 01:15:49 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-01-09 01:34:16 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR adds a missing shell script required by the release pipeline to normalize dates across release-related files. The script was causing workflow failures due to its absence from the repository.

  • Adds scripts/release/update_dates.sh to normalize release dates in CHANGELOG.md, templateDetails.xml, and updates.xml
  • Implements robust error handling with date format validation and regex character escaping
  • Provides clear output messages for successful updates and warnings when files are missing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull request overview This PR adds a missing shell script required by the release pipeline to normalize dates across release-related files. The script was causing workflow failures due to its absence from the repository. - Adds `scripts/release/update_dates.sh` to normalize release dates in CHANGELOG.md, templateDetails.xml, and updates.xml - Implements robust error handling with date format validation and regex character escaping - Provides clear output messages for successful updates and warnings when files are missing --- 💡 <a href="/mokoconsulting-tech/moko-cassiopeia/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@@ -0,0 +29,4 @@
# Accept date and version as arguments
TODAY="${1:-$(date +%Y-%m-%d)}"
VERSION="${2:-unknown}"
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-09 01:34:16 +00:00

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.
@@ -0,0 +68,4 @@
# Update updates.xml - replace the <creationDate> tag
if [ -f "updates.xml" ]; then
sed -i "s|<creationDate>[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}</creationDate>|<creationDate>${TODAY}</creationDate>|" updates.xml
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-01-09 01:34:16 +00:00

The sed commands on lines 63 and 71 will replace ALL occurrences of the creationDate pattern in the respective XML files. While currently each file has only one creationDate tag, this approach is fragile. If the XML files evolve to include multiple update entries (e.g., update history), all creationDate tags would be incorrectly updated to the same date. Consider making the replacement more specific by including more context in the pattern, such as matching within a specific version tag or using a more targeted XML-aware approach.

The sed commands on lines 63 and 71 will replace ALL occurrences of the creationDate pattern in the respective XML files. While currently each file has only one creationDate tag, this approach is fragile. If the XML files evolve to include multiple update entries (e.g., update history), all creationDate tags would be incorrectly updated to the same date. Consider making the replacement more specific by including more context in the pattern, such as matching within a specific version tag or using a more targeted XML-aware approach.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoCassiopeia#40