-
Notifications
You must be signed in to change notification settings - Fork 116
205 lines (180 loc) · 7.9 KB
/
Copy pathrelease-notes-check.yml
File metadata and controls
205 lines (180 loc) · 7.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Release Notes Check
on:
pull_request:
branches:
- Development
types:
- opened
- reopened
- synchronize
- edited
jobs:
check-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_yaml: |
code:
- 'application/single_app/**/*.py'
- 'application/single_app/**/*.js'
- 'application/single_app/**/*.html'
- 'application/single_app/**/*.css'
release_notes:
- 'docs/explanation/release_notes.md'
config:
- 'application/single_app/config.py'
- name: Check for feature/fix keywords in PR
id: check-keywords
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
echo "🔍 Analyzing PR title and body for feature/fix indicators..."
# Convert to lowercase for case-insensitive matching
title_lower=$(echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]')
body_lower=$(echo "$PR_BODY" | tr '[:upper:]' '[:lower:]')
# Check for feature indicators
if echo "$title_lower $body_lower" | grep -qE "(feat|feature|add|new|implement|introduce|enhancement|improve)"; then
echo "has_feature=true" >> $GITHUB_OUTPUT
echo "📦 Feature-related keywords detected"
else
echo "has_feature=false" >> $GITHUB_OUTPUT
fi
# Check for fix indicators
if echo "$title_lower $body_lower" | grep -qE "(fix|bug|patch|resolve|correct|repair|hotfix|issue)"; then
echo "has_fix=true" >> $GITHUB_OUTPUT
echo "🐛 Fix-related keywords detected"
else
echo "has_fix=false" >> $GITHUB_OUTPUT
fi
- name: Determine if release notes update is required
id: require-notes
env:
CODE_CHANGED: ${{ steps.changed-files.outputs.code_any_changed }}
CONFIG_CHANGED: ${{ steps.changed-files.outputs.config_any_changed }}
RELEASE_NOTES_CHANGED: ${{ steps.changed-files.outputs.release_notes_any_changed }}
HAS_FEATURE: ${{ steps.check-keywords.outputs.has_feature }}
HAS_FIX: ${{ steps.check-keywords.outputs.has_fix }}
run: |
echo ""
echo "================================"
echo "📋 PR Analysis Summary"
echo "================================"
echo "Code files changed: $CODE_CHANGED"
echo "Config changed: $CONFIG_CHANGED"
echo "Release notes updated: $RELEASE_NOTES_CHANGED"
echo "Feature keywords found: $HAS_FEATURE"
echo "Fix keywords found: $HAS_FIX"
echo "================================"
echo ""
# Determine if this PR likely needs release notes
needs_notes="false"
reason=""
if [[ "$HAS_FEATURE" == "true" ]]; then
needs_notes="true"
reason="Feature-related keywords detected in PR title/body"
elif [[ "$HAS_FIX" == "true" ]]; then
needs_notes="true"
reason="Fix-related keywords detected in PR title/body"
elif [[ "$CODE_CHANGED" == "true" && "$CONFIG_CHANGED" == "true" ]]; then
needs_notes="true"
reason="Both code and config.py were modified"
fi
echo "needs_notes=$needs_notes" >> $GITHUB_OUTPUT
echo "reason=$reason" >> $GITHUB_OUTPUT
- name: Validate release notes update
env:
CODE_CHANGED: ${{ steps.changed-files.outputs.code_any_changed }}
RELEASE_NOTES_CHANGED: ${{ steps.changed-files.outputs.release_notes_any_changed }}
NEEDS_NOTES: ${{ steps.require-notes.outputs.needs_notes }}
REASON: ${{ steps.require-notes.outputs.reason }}
CODE_FILES: ${{ steps.changed-files.outputs.code_all_changed_files }}
run: |
echo ""
if [[ "$NEEDS_NOTES" == "true" && "$RELEASE_NOTES_CHANGED" != "true" ]]; then
echo "⚠️ =============================================="
echo "⚠️ RELEASE NOTES UPDATE RECOMMENDED"
echo "⚠️ =============================================="
echo ""
echo "📝 Reason: $REASON"
echo ""
echo "This PR appears to contain changes that should be documented"
echo "in the release notes (docs/explanation/release_notes.md)."
echo ""
echo "📁 Code files changed:"
echo "$CODE_FILES" | tr ' ' '\n' | sed 's/^/ - /'
echo ""
echo "💡 Please consider adding an entry to release_notes.md describing:"
echo " • New features added"
echo " • Bug fixes implemented"
echo " • Breaking changes (if any)"
echo " • Files modified"
echo ""
echo "📖 Follow the existing format in release_notes.md"
echo ""
# Exit with warning (non-zero) to flag the PR but not block it
# Change 'exit 0' to 'exit 1' below to make this a hard requirement
exit 0
elif [[ "$RELEASE_NOTES_CHANGED" == "true" ]]; then
echo "✅ Release notes have been updated - great job!"
elif [[ "$CODE_CHANGED" != "true" ]]; then
echo "ℹ️ No significant code changes detected - release notes update not required."
else
echo "ℹ️ Changes appear to be minor - release notes update optional."
fi
echo ""
echo "✅ Release notes check completed successfully."
- name: Post PR comment (when notes needed but missing)
if: steps.require-notes.outputs.needs_notes == 'true' && steps.changed-files.outputs.release_notes_any_changed != 'true'
uses: actions/github-script@v7
with:
script: |
const reason = '${{ steps.require-notes.outputs.reason }}';
// Check if we already commented
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('📋 Release Notes Reminder')
);
if (!botComment) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## 📋 Release Notes Reminder
This PR appears to contain changes that should be documented in the release notes.
**Reason:** ${reason}
### 📝 Please consider updating:
\`docs/explanation/release_notes.md\`
### Template for new features:
\`\`\`markdown
* **Feature Name**
* Brief description of the feature.
* **Key Details**: Important implementation notes.
* **Files Modified**: \`file1.py\`, \`file2.js\`.
* (Ref: related components, patterns)
\`\`\`
### Template for bug fixes:
\`\`\`markdown
* **Bug Fix Title**
* Description of what was fixed.
* **Root Cause**: What caused the issue.
* **Solution**: How it was resolved.
* **Files Modified**: \`file.py\`.
* (Ref: related issue numbers, components)
\`\`\`
---
*This is an automated reminder. If this PR doesn't require release notes (e.g., internal refactoring, documentation-only changes), you can ignore this message.*`
});
}