Files
Krow-workspace/.github/scripts/extract-release-notes.sh
Achintha Isuru be43030058 fix(ci): redirect script messages to stderr and support version format X.Y.Z-suffix
Fixed workflow failure by ensuring only data goes to stdout, not informational messages. Also added support for version format X.Y.Z-suffix in addition to X.Y.Z+build.
2026-03-05 14:10:05 -05:00

66 lines
1.8 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 ## [VERSION] and collect until next ## [ or end of file
NOTES=$(awk "/## \[${VERSION}\]/,/^## \[/" "$CHANGELOG_PATH" | sed '1d;$d' | sed '/^$/d')
if [ -z "$NOTES" ]; then
echo "⚠️ Warning: No CHANGELOG entry found for version $VERSION" >&2
NOTES="Release $VERSION for $APP_NAME
⚠️ No CHANGELOG entry found for this version. Please update the CHANGELOG manually.
**Environment:** $ENV
**Tag:** $TAG_NAME"
else
echo "✅ Extracted release notes for version $VERSION" >&2
NOTES="# $APP_NAME - Release $VERSION
$NOTES
---
**Environment:** $ENV
**Tag:** $TAG_NAME"
fi
else
echo "⚠️ Warning: CHANGELOG not found at $CHANGELOG_PATH" >&2
NOTES="Release $VERSION for $APP_NAME
**Environment:** $ENV
**Tag:** $TAG_NAME"
fi
# Save to output file
echo "$NOTES" > "$OUTPUT_FILE"
echo "✅ Release notes saved to $OUTPUT_FILE" >&2