@@ -23,11 +23,18 @@ jobs:
2323 - name : Find Readme File
2424 id : find_readme
2525 run : |
26- readme_file=$(find . -type f -iname "readme.*" | head -n 1)
27- if [ -n "$readme_file" ]; then
28- echo "Readme file found: $readme_file"
29- echo "readme_file=$readme_file" >> $GITHUB_ENV
30- else
26+ for file in readme.txt Readme.txt README.txt README.md Readme.md readme.md; do
27+ if [ -f "$file" ]; then
28+ echo "Readme file found: $file"
29+ echo "readme_file=$file" >> $GITHUB_ENV
30+ break
31+ fi
32+ done
33+
34+ # Ensure the variable is available within the current step
35+ source $GITHUB_ENV
36+
37+ if [ -z "$readme_file" ]; then
3138 echo "::error::Readme file not found."
3239 exit 1
3340 fi
@@ -36,56 +43,78 @@ jobs:
3643 id : release_notes
3744 run : |
3845 changelog_section_start="== Changelog =="
39- current_tag="${{ github.ref_name }}"
40- readme_file="${{ env.readme_file }}"
46+ readme_file="$readme_file"
4147
42- # Extract the version (strip 'refs/tags/' if it exists)
43- version=${current_tag#refs/tags/}
48+ # Extract the tag name from GITHUB_REF (plugin_version)
49+ if [[ "$GITHUB_REF" == refs/tags/* ]]; then
50+ plugin_version="${GITHUB_REF#refs/tags/}"
51+ echo "DEBUG: Plugin latest version found: $plugin_version."
52+ else
53+ echo "::error::This workflow must be triggered by a tag push."
54+ exit 1
55+ fi
4456
45- # Read lines from the changelog section
4657 in_changelog=0
58+ found_version=0
4759 release_notes=""
48- capturing_version=0
60+
61+ echo "DEBUG: Starting to extract release notes from $readme_file for version $plugin_version."
62+
4963 while IFS= read -r line; do
50- # Start capturing after finding the changelog section
64+ echo "DEBUG: Processing line: $line"
65+
66+ # Start processing after the changelog header
5167 if [[ "$line" == "$changelog_section_start" ]]; then
5268 in_changelog=1
69+ echo "DEBUG: Found changelog section header."
5370 continue
5471 fi
5572
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
73+ # Skip if not in changelog section
74+ if [[ $in_changelog -eq 0 ]]; then
75+ echo "DEBUG: Skipping line (not in changelog section)."
76+ continue
6577 fi
6678
67- # Capture lines only for the current version
68- if [[ $capturing_version -eq 1 && -n "$line" ]]; then
69- release_notes+="$line\n"
79+ # Check for the current version header
80+ if [[ "$line" == "= ${plugin_version} =" ]]; then
81+ found_version=1
82+ echo "DEBUG: Found version header for $plugin_version."
83+ continue
84+ fi
85+
86+ # Break if a new version header is found after the current version
87+ if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^= [0-9]+\.[0-9]+\.[0-9]+ =$'; then
88+ echo "DEBUG: Found a new version header. Stopping collection."
89+ break
90+ fi
91+
92+ # Collect lines starting with '*' if we are in the current version section
93+ if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^\*'; then
94+ echo "DEBUG: Found changelog entry: $line"
95+ release_notes+="${line}\n"
96+ continue
97+ fi
98+
99+ # Log skipped lines in the current version section
100+ if [[ $found_version -eq 1 ]]; then
101+ echo "DEBUG: Skipping line (not a changelog entry): $line"
70102 fi
71103 done < "$readme_file"
72104
73105 if [[ -z "$release_notes" ]]; then
74- echo "::error::Failed to extract release notes for version $version ."
106+ echo "::error::Failed to extract release notes for version ${plugin_version} ."
75107 exit 1
76108 fi
77109
78- # Debug: Print extracted release notes
79- echo "Extracted release notes for version $version :"
80- printf "%b" "$release_notes"
110+ echo "DEBUG: Successfully extracted release notes."
111+ echo "DEBUG: Release notes content :"
112+ echo -e "$release_notes"
81113
82- # Set output
83- echo "::set-output name=notes::$(printf "%b" "$release_notes")"
84-
85- - name : Debug Release Notes
86- run : |
87- echo "Debugging Release Notes:"
88- echo "${{ steps.release_notes.outputs.notes }}"
114+ # Write the release notes with actual line breaks
115+ echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
116+ echo -e "$release_notes" >> $GITHUB_ENV
117+ echo "EOF" >> $GITHUB_ENV
89118
90119 - name : WordPress Plugin Deploy
91120 id : deploy
@@ -97,10 +126,10 @@ jobs:
97126 uses : softprops/action-gh-release@v2
98127 with :
99128 tag_name : ${{ github.ref_name }}
100- body : ${{ steps.release_notes.outputs.notes }}
129+ body : ${{ env.RELEASE_NOTES }}
101130 files : ${{github.workspace}}/${{ github.event.repository.name }}.zip
102131
103132env :
104133 SVN_PASSWORD : ${{ secrets.SVN_PASSWORD }}
105134 SVN_USERNAME : ${{ secrets.SVN_USERNAME }}
106- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
135+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments