@@ -11,46 +11,125 @@ jobs:
1111 runs-on : ubuntu-latest
1212 steps :
1313 - uses : actions/checkout@v3
14+
15+ - name : Debug File List
16+ run : ls -R
17+
1418 - name : Install SVN (Subversion)
1519 run : |
1620 sudo apt-get update
1721 sudo apt-get install subversion
1822
19- - name : WordPress Plugin Deploy
20- id : deploy
21- uses : 10up/action-wordpress-plugin-deploy@stable
22- with :
23- generate-zip : true
24-
2523 - name : Find Readme File
2624 id : find_readme
2725 run : |
28- for file in README .txt README.md Readme .txt Readme .md readme.txt readme.md; do
26+ for file in readme .txt Readme.txt README .txt README .md Readme.md readme.md; do
2927 if [ -f "$file" ]; then
30- echo "::set-output name=readme_file::$file"
28+ echo "Readme file found: $file"
29+ echo "readme_file=$file" >> $GITHUB_ENV
3130 break
3231 fi
3332 done
3433
34+ # Ensure the variable is available within the current step
35+ source $GITHUB_ENV
36+
37+ if [ -z "$readme_file" ]; then
38+ echo "::error::Readme file not found."
39+ exit 1
40+ fi
41+
3542 - name : Extract Release Notes
3643 id : release_notes
3744 run : |
38- if [[ -z "${{ steps.find_readme.outputs.readme_file }}" ]]; then
39- echo "::error::Readme file not found."
45+ changelog_section_start="== Changelog =="
46+ readme_file="$readme_file"
47+
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."
4054 exit 1
4155 fi
4256
43- release_notes=$(grep '== Changelog ==' "${{ steps.find_readme.outputs.readme_file }}" | head -n -1 | tail -n +2)
44- echo "::set-output name=notes::$release_notes"
57+ in_changelog=0
58+ found_version=0
59+ release_notes=""
60+
61+ echo "DEBUG: Starting to extract release notes from $readme_file for version $plugin_version."
62+
63+ while IFS= read -r line; do
64+ echo "DEBUG: Processing line: $line"
65+
66+ # Start processing after the changelog header
67+ if [[ "$line" == "$changelog_section_start" ]]; then
68+ in_changelog=1
69+ echo "DEBUG: Found changelog section header."
70+ continue
71+ fi
72+
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
77+ fi
78+
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"
102+ fi
103+ done < "$readme_file"
104+
105+ if [[ -z "$release_notes" ]]; then
106+ echo "::error::Failed to extract release notes for version ${plugin_version}."
107+ exit 1
108+ fi
109+
110+ echo "DEBUG: Successfully extracted release notes."
111+ echo "DEBUG: Release notes content:"
112+ echo -e "$release_notes"
113+
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
118+
119+ - name : WordPress Plugin Deploy
120+ id : deploy
121+ uses : 10up/action-wordpress-plugin-deploy@stable
122+ with :
123+ generate-zip : true
45124
46125 - name : Create GitHub Release
47126 uses : softprops/action-gh-release@v2
48127 with :
49128 tag_name : ${{ github.ref_name }}
50- body : ${{ steps.release_notes.outputs.notes }}
129+ body : ${{ env.RELEASE_NOTES }}
51130 files : ${{github.workspace}}/${{ github.event.repository.name }}.zip
52131
53132env :
54133 SVN_PASSWORD : ${{ secrets.SVN_PASSWORD }}
55134 SVN_USERNAME : ${{ secrets.SVN_USERNAME }}
56- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
135+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments