Files
Krow-workspace/.github/scripts/extract-release-notes.sh
Achintha Isuru 107ce1d48a feat(ci): update release notes format to new template
Updated extract-release-notes.sh to follow new format:

**Environment:** {ENV}

**Tag:** {TAG}

## What is new in this release

{changelog content}

Improvements:

- Moved environment and tag info to the top

- Added 'What is new in this release' heading

- Improved awk pattern to properly extract changelog sections

- Support both [vX.Y.Z] and [X.Y.Z] version formats in CHANGELOG

- Removes unnecessary app name and separator lines

Testing:

 worker-mobile-app: Extracts content from apps/mobile/apps/staff/CHANGELOG.md

 client-mobile-app: Extracts content from apps/mobile/apps/client/CHANGELOG.md

 Handles [v0.0.1-m3] format correctly
2026-03-05 15:09:32 -05:00

72 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Extract release notes from CHANGELOG for a specific version
# Usage: ./extract-release-notes.sh <app> <version> <environment> <tag_name> <output_file>
set -e
APP=$1
VERSION=$2
ENV=$3
TAG_NAME=$4
OUTPUT_FILE=$5
if [ -z "$APP" ] || [ -z "$VERSION" ] || [ -z "$ENV" ] || [ -z "$TAG_NAME" ] || [ -z "$OUTPUT_FILE" ]; then
echo "❌ Error: Missing required parameters" >&2
echo "Usage: ./extract-release-notes.sh <app> <version> <environment> <tag_name> <output_file>" >&2
exit 1
fi
# Determine CHANGELOG path and app name
if [ "$APP" = "worker-mobile-app" ]; then
CHANGELOG_PATH="apps/mobile/apps/staff/CHANGELOG.md"
APP_NAME="Staff Product (Worker)"
else
CHANGELOG_PATH="apps/mobile/apps/client/CHANGELOG.md"
APP_NAME="Client Product"
fi
# Try to extract release notes for this version
if [ -f "$CHANGELOG_PATH" ]; then
echo "📝 Found CHANGELOG at $CHANGELOG_PATH" >&2
# Extract section for this version
# Look for ## [vVERSION] or ## [VERSION] and collect content until next ## [ header
# Try with 'v' prefix first (common format), then without
CHANGELOG_CONTENT=$(awk "/^## \[v${VERSION}\]/{flag=1; next} /^## \[/{flag=0} flag" "$CHANGELOG_PATH")
# If still empty, try without 'v' prefix
if [ -z "$CHANGELOG_CONTENT" ]; then
CHANGELOG_CONTENT=$(awk "/^## \[${VERSION}\]/{flag=1; next} /^## \[/{flag=0} flag" "$CHANGELOG_PATH")
fi
if [ -z "$CHANGELOG_CONTENT" ]; then
echo "⚠️ Warning: No CHANGELOG entry found for version $VERSION" >&2
NOTES="**Environment:** $ENV
**Tag:** $TAG_NAME
## What is new in this release
⚠️ No CHANGELOG entry found for this version. Please update the CHANGELOG manually."
else
echo "✅ Extracted release notes for version $VERSION" >&2
NOTES="**Environment:** $ENV
**Tag:** $TAG_NAME
## What is new in this release
$CHANGELOG_CONTENT"
fi
else
echo "⚠️ Warning: CHANGELOG not found at $CHANGELOG_PATH" >&2
NOTES="**Environment:** $ENV
**Tag:** $TAG_NAME
## What is new in this release
⚠️ CHANGELOG file not found at $CHANGELOG_PATH"
fi
# Save to output file
echo "$NOTES" > "$OUTPUT_FILE"
echo "✅ Release notes saved to $OUTPUT_FILE" >&2