77
88jobs :
99 tag :
10- name : Deploy Plugin Tag
10+ name : New tag
1111 runs-on : ubuntu-latest
12-
1312 steps :
1413 - uses : actions/checkout@v3
1514
@@ -24,79 +23,105 @@ jobs:
2423 - name : Find Readme File
2524 id : find_readme
2625 run : |
27- readme_file=$(find . -type f -iname "readme.*" | 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
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
3238 echo "::error::Readme file not found."
3339 exit 1
3440 fi
3541
3642 - name : Extract Release Notes
3743 id : release_notes
3844 run : |
39- # Define variables
4045 changelog_section_start="== Changelog =="
41- current_tag="${{ github.ref_name }}"
42- readme_file="${{ env.readme_file }}"
46+ readme_file="$readme_file"
4347
44- # Extract version from tag (strip 'refs/tags/' if it exists)
45- 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
4656
47- # Initialize variables
4857 in_changelog=0
49- capturing_version =0
58+ found_version =0
5059 release_notes=""
5160
61+ echo "DEBUG: Starting to extract release notes from $readme_file for version $plugin_version."
62+
5263 while IFS= read -r line; do
53- # Start capturing after finding the changelog section
64+ echo "DEBUG: Processing line: $line"
65+
66+ # Start processing after the changelog header
5467 if [[ "$line" == "$changelog_section_start" ]]; then
5568 in_changelog=1
69+ echo "DEBUG: Found changelog section header."
5670 continue
5771 fi
5872
59- # Skip lines before the changelog section
73+ # Skip if not in changelog section
6074 if [[ $in_changelog -eq 0 ]]; then
75+ echo "DEBUG: Skipping line (not in changelog section)."
6176 continue
6277 fi
6378
64- # Start capturing if the line matches the current version
65- if [[ "$line" == "= $version =" ]]; then
66- capturing_version =1
67- 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. "
6883 continue
6984 fi
7085
71- # Stop capturing when a new version is detected
72- if [[ $capturing_version -eq 1 && "$line" =~ ^= ]]; then
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."
7389 break
7490 fi
7591
76- # Add the line to the release notes if we are capturing
77- if [[ $capturing_version -eq 1 ]]; then
78- release_notes+="$line\n"
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"
79102 fi
80103 done < "$readme_file"
81104
82- # Check if release notes were extracted
83105 if [[ -z "$release_notes" ]]; then
84- echo "::error::Failed to extract release notes for version $version ."
106+ echo "::error::Failed to extract release notes for version ${plugin_version} ."
85107 exit 1
86108 fi
87109
88- # Debug: Print extracted release notes
89- echo "Extracted release notes for version $version:"
90- printf "%b" "$release_notes"
91-
92- # Set output for release notes
93- echo "::set-output name=notes::$(printf "%b" "$release_notes")"
94-
95- - name : Debug Release Notes
96- run : |
97- echo "Debugging Release Notes:"
98- echo "${{ steps.release_notes.outputs.notes }}"
99-
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: Deploy WordPress.org Assets
120+ # uses: 10up/action-wordpress-plugin-asset-update@stable
121+ # env:
122+ # SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
123+ # SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
124+
100125 - name : WordPress Plugin Deploy
101126 id : deploy
102127 uses : 10up/action-wordpress-plugin-deploy@stable
@@ -107,7 +132,7 @@ jobs:
107132 uses : softprops/action-gh-release@v2
108133 with :
109134 tag_name : ${{ github.ref_name }}
110- body : ${{ steps.release_notes.outputs.notes }}
135+ body : ${{ env.RELEASE_NOTES }}
111136 files : ${{github.workspace}}/${{ github.event.repository.name }}.zip
112137
113138env :
0 commit comments