@@ -11,46 +11,125 @@ jobs:
11
11
runs-on : ubuntu-latest
12
12
steps :
13
13
- uses : actions/checkout@v3
14
+
15
+ - name : Debug File List
16
+ run : ls -R
17
+
14
18
- name : Install SVN (Subversion)
15
19
run : |
16
20
sudo apt-get update
17
21
sudo apt-get install subversion
18
22
19
- - name : WordPress Plugin Deploy
20
- id : deploy
21
- uses : 10up/action-wordpress-plugin-deploy@stable
22
- with :
23
- generate-zip : true
24
-
25
23
- name : Find Readme File
26
24
id : find_readme
27
25
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
29
27
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
31
30
break
32
31
fi
33
32
done
34
33
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
+
35
42
- name : Extract Release Notes
36
43
id : release_notes
37
44
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."
40
54
exit 1
41
55
fi
42
56
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
45
124
46
125
- name : Create GitHub Release
47
126
uses : softprops/action-gh-release@v2
48
127
with :
49
128
tag_name : ${{ github.ref_name }}
50
- body : ${{ steps.release_notes.outputs.notes }}
129
+ body : ${{ env.RELEASE_NOTES }}
51
130
files : ${{github.workspace}}/${{ github.event.repository.name }}.zip
52
131
53
132
env :
54
133
SVN_PASSWORD : ${{ secrets.SVN_PASSWORD }}
55
134
SVN_USERNAME : ${{ secrets.SVN_USERNAME }}
56
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
135
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments