@@ -23,18 +23,12 @@ jobs:
2323 - name : Find Readme File
2424 id : find_readme
2525 run : |
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
26+ #readme_file=$(find . -type f -iname "readme.*" | head -n 1)
27+ readme_file=$(find . -maxdepth 1 -type f -iname "readme.txt" | head -n 1)
28+ if [ -n "$readme_file" ]; then
29+ echo "Readme file found: $readme_file"
30+ echo "readme_file=$readme_file" >> $GITHUB_ENV
31+ else
3832 echo "::error::Readme file not found."
3933 exit 1
4034 fi
@@ -43,78 +37,58 @@ jobs:
4337 id : release_notes
4438 run : |
4539 changelog_section_start="== Changelog =="
46- readme_file="$readme_file"
40+ current_tag="${{ github.ref_name }}"
41+ readme_file="${{ env.readme_file }}"
4742
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
43+ # Extract the version (strip 'refs/tags/' if it exists)
44+ version=${current_tag#refs/tags/}
5645
46+ # Read lines from the changelog section
5747 in_changelog=0
58- found_version=0
5948 release_notes=""
60-
61- echo "DEBUG: Starting to extract release notes from $readme_file for version $plugin_version."
62-
49+ capturing_version=0
6350 while IFS= read -r line; do
64- echo "DEBUG: Processing line: $line"
65-
66- # Start processing after the changelog header
51+ # Start capturing after finding the changelog section
6752 if [[ "$line" == "$changelog_section_start" ]]; then
6853 in_changelog=1
69- echo "DEBUG: Found changelog section header."
7054 continue
7155 fi
7256
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
57+ # Stop capturing if we encounter a new version or the end of the file
58+ if [[ $in_changelog -eq 1 && "$line" =~ ^= ]]; then
59+ # Check if this is the current version
60+ if [[ "$line" == "= $version =" ]]; then
61+ capturing_version=1
62+ elif [[ $capturing_version -eq 1 ]]; then
63+ # Stop if we see the next version
64+ break
65+ fi
7766 fi
7867
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"
68+ # Capture lines only for the current version
69+ if [[ $capturing_version -eq 1 && -n "$line" ]]; then
70+ release_notes+="$line\n"
10271 fi
10372 done < "$readme_file"
10473
10574 if [[ -z "$release_notes" ]]; then
106- echo "::error::Failed to extract release notes for version ${plugin_version} ."
75+ echo "::error::Failed to extract release notes for version $version ."
10776 exit 1
10877 fi
10978
110- echo "DEBUG: Successfully extracted release notes."
111- echo "DEBUG: Release notes content :"
112- echo -e "$release_notes"
79+ # Debug: Print extracted release notes
80+ echo "Extracted release notes for version $version :"
81+ printf "%b" "$release_notes"
11382
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
83+ # Set output (fixed, now using Environment File)
84+ echo "notes<<EOF" >> $GITHUB_OUTPUT
85+ printf "%b\n" "$release_notes" >> $GITHUB_OUTPUT
86+ echo "EOF" >> $GITHUB_OUTPUT
87+
88+ - name : Debug Release Notes
89+ run : |
90+ echo "Debugging Release Notes:"
91+ echo "${{ steps.release_notes.outputs.notes }}"
11892
11993 - name : WordPress Plugin Deploy
12094 id : deploy
@@ -126,10 +100,10 @@ jobs:
126100 uses : softprops/action-gh-release@v2
127101 with :
128102 tag_name : ${{ github.ref_name }}
129- body : ${{ env.RELEASE_NOTES }}
103+ body : ${{ steps.release_notes.outputs.notes }}
130104 files : ${{github.workspace}}/${{ github.event.repository.name }}.zip
131105
132106env :
133107 SVN_PASSWORD : ${{ secrets.SVN_PASSWORD }}
134108 SVN_USERNAME : ${{ secrets.SVN_USERNAME }}
135- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
109+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments