7
7
8
8
jobs :
9
9
tag :
10
- name : Deploy Plugin Tag
10
+ name : New tag
11
11
runs-on : ubuntu-latest
12
-
13
12
steps :
14
13
- uses : actions/checkout@v3
15
14
@@ -24,79 +23,105 @@ jobs:
24
23
- name : Find Readme File
25
24
id : find_readme
26
25
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
32
38
echo "::error::Readme file not found."
33
39
exit 1
34
40
fi
35
41
36
42
- name : Extract Release Notes
37
43
id : release_notes
38
44
run : |
39
- # Define variables
40
45
changelog_section_start="== Changelog =="
41
- current_tag="${{ github.ref_name }}"
42
- readme_file="${{ env.readme_file }}"
46
+ readme_file="$readme_file"
43
47
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
46
56
47
- # Initialize variables
48
57
in_changelog=0
49
- capturing_version =0
58
+ found_version =0
50
59
release_notes=""
51
60
61
+ echo "DEBUG: Starting to extract release notes from $readme_file for version $plugin_version."
62
+
52
63
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
54
67
if [[ "$line" == "$changelog_section_start" ]]; then
55
68
in_changelog=1
69
+ echo "DEBUG: Found changelog section header."
56
70
continue
57
71
fi
58
72
59
- # Skip lines before the changelog section
73
+ # Skip if not in changelog section
60
74
if [[ $in_changelog -eq 0 ]]; then
75
+ echo "DEBUG: Skipping line (not in changelog section)."
61
76
continue
62
77
fi
63
78
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. "
68
83
continue
69
84
fi
70
85
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."
73
89
break
74
90
fi
75
91
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"
79
102
fi
80
103
done < "$readme_file"
81
104
82
- # Check if release notes were extracted
83
105
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} ."
85
107
exit 1
86
108
fi
87
109
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
+
100
125
- name : WordPress Plugin Deploy
101
126
id : deploy
102
127
uses : 10up/action-wordpress-plugin-deploy@stable
@@ -107,7 +132,7 @@ jobs:
107
132
uses : softprops/action-gh-release@v2
108
133
with :
109
134
tag_name : ${{ github.ref_name }}
110
- body : ${{ steps.release_notes.outputs.notes }}
135
+ body : ${{ env.RELEASE_NOTES }}
111
136
files : ${{github.workspace}}/${{ github.event.repository.name }}.zip
112
137
113
138
env :
0 commit comments