@@ -88,30 +88,48 @@ jobs:
8888 run : |
8989 # Extract the section for the current tag from CHANGELOG.md
9090 TAG_NAME="${GITHUB_REF_NAME:-$(git describe --tags --abbrev=0)}"
91- VERSION="${TAG_NAME#v}"
91+ VERSION="${TAG_NAME#v}" # Remove 'v' prefix if present
9292
9393 if [ ! -f "CHANGELOG.md" ]; then
9494 echo "section=No changelog available for this release." >> $GITHUB_OUTPUT
9595 exit 0
9696 fi
9797
98- # Extract content between this version header and the next version header
99- # Handle both [version] and version formats in headers
100- SECTION=$(awk "/^## \[?${VERSION}\]?/{found=1; next} /^## \[?[0-9]+\.[0-9]+\.[0-9]+\]?/{if(found) exit} found{print}" CHANGELOG.md)
98+ echo "Looking for version: ${VERSION} (tag: ${TAG_NAME})"
99+ echo "CHANGELOG.md contents:"
100+ head -50 CHANGELOG.md
101101
102- # Trim leading/trailing whitespace
103- SECTION=$(echo "$SECTION" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
102+ # Try multiple patterns to find the version section
103+ # Pattern 1: [vX.Y.Z] or [X.Y.Z] with link
104+ SECTION=$(awk "/^## \[v?${VERSION}\]/{found=1; next} /^## /{if(found) exit} found{print}" CHANGELOG.md)
104105
105- # If extraction failed or empty, try alternative patterns
106+ # Trim leading/trailing whitespace and empty lines
107+ SECTION=$(echo "$SECTION" | sed '/^[[:space:]]*$/d' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
108+
109+ echo "Extracted section (pattern 1): '$SECTION'"
110+
111+ # Pattern 2: Try with the v prefix explicitly
112+ if [ -z "$SECTION" ]; then
113+ SECTION=$(awk "/^## \[${TAG_NAME}\]/{found=1; next} /^## /{if(found) exit} found{print}" CHANGELOG.md)
114+ SECTION=$(echo "$SECTION" | sed '/^[[:space:]]*$/d' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
115+ echo "Extracted section (pattern 2): '$SECTION'"
116+ fi
117+
118+ # Pattern 3: Without brackets
106119 if [ -z "$SECTION" ]; then
107- # Try with just the version number in various formats
108- SECTION=$(awk "/^##.*${VERSION}/{found=1; next} /^## /{if(found) exit} found{print}" CHANGELOG.md )
109- SECTION=$( echo "$SECTION" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
120+ SECTION=$(awk "/^## v?${VERSION}/{found=1; next} /^## /{if(found) exit} found{print}" CHANGELOG.md)
121+ SECTION=$(echo "$SECTION" | sed '/^[[:space:]]*$/d' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' )
122+ echo "Extracted section (pattern 3): '$SECTION'"
110123 fi
111124
112- # If still empty, provide a meaningful fallback
125+ # If still empty, the version exists but has no documented changes
113126 if [ -z "$SECTION" ]; then
114- SECTION="No detailed changelog available for version ${VERSION}."
127+ # Check if the version header exists at all
128+ if grep -q "## \[v\?${VERSION}\]" CHANGELOG.md || grep -q "## v\?${VERSION}" CHANGELOG.md; then
129+ SECTION="This release contains minor updates. See commit history for details."
130+ else
131+ SECTION="No changelog entry found for version ${VERSION}."
132+ fi
115133 fi
116134
117135 # Write to output (handle multiline)
0 commit comments