@@ -36,35 +36,51 @@ jobs:
3636 id : release_notes
3737 run : |
3838 changelog_section_start="== Changelog =="
39+ current_tag="${{ github.ref_name }}"
3940 readme_file="${{ env.readme_file }}"
4041
42+ # Extract the version (strip 'refs/tags/' if it exists)
43+ version=${current_tag#refs/tags/}
44+
4145 # Read lines from the changelog section
4246 in_changelog=0
4347 release_notes=""
48+ capturing_version=0
4449 while IFS= read -r line; do
50+ # Start capturing after finding the changelog section
4551 if [[ "$line" == "$changelog_section_start" ]]; then
4652 in_changelog=1
4753 continue
4854 fi
49- if [[ $in_changelog -eq 1 && "$line" =~ ^== ]]; then
50- break
55+
56+ # Stop capturing if we encounter a new version or the end of the file
57+ if [[ $in_changelog -eq 1 && "$line" =~ ^= ]]; then
58+ # Check if this is the current version
59+ if [[ "$line" == "= $version =" ]]; then
60+ capturing_version=1
61+ elif [[ $capturing_version -eq 1 ]]; then
62+ # Stop if we see the next version
63+ break
64+ fi
5165 fi
52- if [[ $in_changelog -eq 1 && -n "$line" ]]; then
66+
67+ # Capture lines only for the current version
68+ if [[ $capturing_version -eq 1 && -n "$line" ]]; then
5369 release_notes+="$line\n"
5470 fi
5571 done < "$readme_file"
5672
5773 if [[ -z "$release_notes" ]]; then
58- echo "::error::Failed to extract release notes from the changelog section ."
74+ echo "::error::Failed to extract release notes for version $version ."
5975 exit 1
6076 fi
6177
6278 # Debug: Print extracted release notes
63- echo "Extracted release notes:"
64- echo "$release_notes"
79+ echo "Extracted release notes for version $version :"
80+ printf "%b" "$release_notes"
6581
6682 # Set output
67- echo "::set-output name=notes::$release_notes"
83+ echo "::set-output name=notes::$(printf "%b" "$ release_notes") "
6884
6985 - name : Debug Release Notes
7086 run : |
0 commit comments