Skip to content

Commit 3d1ef2b

Browse files
jstirnamanclaude
andcommitted
feat(helper-scripts): Enhance release notes generation with multi-repo and API change detection
- Add support for multiple repositories (primary + additional repos) - Automatically fetch latest commits from all repositories by default - Add --no-fetch and --pull command-line options for different workflows - Detect and categorize REST API changes across v1, v2, v3 endpoints - Include specific API endpoint analysis (/write, /query, /ping, /health, /metrics) - Add repository tagging to commit categorization for multi-repo visibility - Improve error handling with fallback options for git operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 1861136 commit 3d1ef2b

File tree

1 file changed

+272
-53
lines changed

1 file changed

+272
-53
lines changed
Lines changed: 272 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,55 @@
11
#!/bin/bash
22

33
# Script to generate release notes for InfluxDB v3.x releases
4-
# Usage: ./generate-release-notes.sh <from_version> <to_version> <repo_path>
4+
# Usage: ./generate-release-notes.sh [--no-fetch] [--pull] <from_version> <to_version> <primary_repo_path> [additional_repo_paths...]
5+
#
6+
# Options:
7+
# --no-fetch Skip fetching latest commits from remote
8+
# --pull Pull latest changes (implies fetch) - use with caution as it may change your working directory
9+
#
10+
# Example: ./generate-release-notes.sh v3.1.0 v3.2.0 /path/to/influxdb /path/to/influxdb_pro /path/to/influxdb_iox
11+
# Example: ./generate-release-notes.sh --no-fetch v3.1.0 v3.2.0 /path/to/influxdb
12+
# Example: ./generate-release-notes.sh --pull v3.1.0 v3.2.0 /path/to/influxdb /path/to/influxdb_pro
513

614
set -e
715

8-
# Default values
9-
REPO_PATH="${3:-/Users/ja/Documents/github/influxdb}"
16+
# Parse command line options
17+
FETCH_COMMITS=true
18+
PULL_COMMITS=false
19+
20+
while [[ $# -gt 0 ]]; do
21+
case $1 in
22+
--no-fetch)
23+
FETCH_COMMITS=false
24+
shift
25+
;;
26+
--pull)
27+
PULL_COMMITS=true
28+
FETCH_COMMITS=true
29+
shift
30+
;;
31+
-*)
32+
echo "Unknown option $1"
33+
exit 1
34+
;;
35+
*)
36+
break
37+
;;
38+
esac
39+
done
40+
41+
# Parse remaining arguments
1042
FROM_VERSION="${1:-v3.1.0}"
1143
TO_VERSION="${2:-v3.2.0}"
44+
PRIMARY_REPO="${3:-/Users/ja/Documents/github/influxdb}"
45+
46+
# Collect additional repositories (all arguments after the third)
47+
ADDITIONAL_REPOS=()
48+
shift 3 2>/dev/null || true
49+
while [ $# -gt 0 ]; do
50+
ADDITIONAL_REPOS+=("$1")
51+
shift
52+
done
1253

1354
# Colors for output
1455
RED='\033[0;31m'
@@ -18,36 +59,170 @@ BLUE='\033[0;34m'
1859
NC='\033[0m' # No Color
1960

2061
echo -e "${BLUE}Generating release notes for ${TO_VERSION}${NC}"
21-
echo -e "Repository: ${REPO_PATH}"
62+
echo -e "Primary Repository: ${PRIMARY_REPO}"
63+
if [ ${#ADDITIONAL_REPOS[@]} -gt 0 ]; then
64+
echo -e "Additional Repositories:"
65+
for repo in "${ADDITIONAL_REPOS[@]}"; do
66+
echo -e " - ${repo}"
67+
done
68+
fi
2269
echo -e "From: ${FROM_VERSION} To: ${TO_VERSION}\n"
2370

2471
# Function to extract PR number from commit message
2572
extract_pr_number() {
2673
echo "$1" | grep -oE '#[0-9]+' | head -1 | sed 's/#//'
2774
}
2875

76+
# Function to get commits from a repository
77+
get_commits_from_repo() {
78+
local repo_path="$1"
79+
local pattern="$2"
80+
local format="${3:-%h %s}"
81+
82+
if [ -d "$repo_path" ]; then
83+
git -C "$repo_path" log --format="$format" "${FROM_VERSION}..${TO_VERSION}" 2>/dev/null | grep -E "$pattern" || true
84+
fi
85+
}
86+
87+
# Function to analyze API-related commits
88+
analyze_api_changes() {
89+
local repo_path="$1"
90+
local repo_name="$2"
91+
92+
if [ ! -d "$repo_path" ]; then
93+
return
94+
fi
95+
96+
# Look for API-related file changes
97+
local api_files=$(git -C "$repo_path" diff --name-only "${FROM_VERSION}..${TO_VERSION}" 2>/dev/null | grep -E "(api|handler|endpoint|route)" | head -10 || true)
98+
99+
# Look for specific API endpoint patterns in commit messages and diffs
100+
local api_commits=$(git -C "$repo_path" log --format="%h %s" "${FROM_VERSION}..${TO_VERSION}" 2>/dev/null | \
101+
grep -iE "(api|endpoint|/write|/query|/ping|/health|/metrics|v1|v2|v3)" || true)
102+
103+
if [ -n "$api_files" ] || [ -n "$api_commits" ]; then
104+
echo " Repository: $repo_name"
105+
if [ -n "$api_files" ]; then
106+
echo " Modified API files:"
107+
echo "$api_files" | while read -r file; do
108+
echo " - $file"
109+
done
110+
fi
111+
if [ -n "$api_commits" ]; then
112+
echo " API-related commits:"
113+
echo "$api_commits" | while read -r commit; do
114+
echo " - $commit"
115+
done
116+
fi
117+
echo
118+
fi
119+
}
120+
29121
# Get the release date
30-
RELEASE_DATE=$(git -C "$REPO_PATH" log -1 --format=%ai "$TO_VERSION" | cut -d' ' -f1)
122+
RELEASE_DATE=$(git -C "$PRIMARY_REPO" log -1 --format=%ai "$TO_VERSION" | cut -d' ' -f1)
31123
echo -e "${GREEN}Release Date: ${RELEASE_DATE}${NC}\n"
32124

33-
# Collect commits by category
34-
echo -e "${YELLOW}Analyzing commits...${NC}"
125+
# Create array of all repositories
126+
ALL_REPOS=("$PRIMARY_REPO")
127+
for repo in "${ADDITIONAL_REPOS[@]}"; do
128+
ALL_REPOS+=("$repo")
129+
done
35130

36-
# Features
37-
echo -e "\n${GREEN}Features:${NC}"
38-
FEATURES=$(git -C "$REPO_PATH" log --format="%h %s" "${FROM_VERSION}..${TO_VERSION}" | grep -E "^[a-f0-9]+ feat:" | sed 's/^[a-f0-9]* feat: //')
131+
# Fetch latest commits from all repositories (if enabled)
132+
if [ "$FETCH_COMMITS" = true ]; then
133+
if [ "$PULL_COMMITS" = true ]; then
134+
echo -e "${YELLOW}Pulling latest changes from all repositories...${NC}"
135+
echo -e "${RED}Warning: This will modify your working directories!${NC}"
136+
else
137+
echo -e "${YELLOW}Fetching latest commits from all repositories...${NC}"
138+
fi
139+
140+
for repo in "${ALL_REPOS[@]}"; do
141+
if [ -d "$repo" ]; then
142+
repo_name=$(basename "$repo")
143+
144+
if [ "$PULL_COMMITS" = true ]; then
145+
echo -e " Pulling changes in $repo_name..."
146+
if git -C "$repo" pull origin 2>/dev/null; then
147+
echo -e " ${GREEN}${NC} Successfully pulled changes in $repo_name"
148+
else
149+
echo -e " ${RED}${NC} Failed to pull changes in $repo_name (trying fetch only)"
150+
if git -C "$repo" fetch origin 2>/dev/null; then
151+
echo -e " ${GREEN}${NC} Successfully fetched from $repo_name"
152+
else
153+
echo -e " ${RED}${NC} Failed to fetch from $repo_name (continuing with local commits)"
154+
fi
155+
fi
156+
else
157+
echo -e " Fetching from $repo_name..."
158+
if git -C "$repo" fetch origin 2>/dev/null; then
159+
echo -e " ${GREEN}${NC} Successfully fetched from $repo_name"
160+
else
161+
echo -e " ${RED}${NC} Failed to fetch from $repo_name (continuing with local commits)"
162+
fi
163+
fi
164+
else
165+
echo -e " ${RED}${NC} Repository not found: $repo"
166+
fi
167+
done
168+
else
169+
echo -e "${YELLOW}Skipping fetch (using local commits only)${NC}"
170+
fi
171+
172+
# Collect commits by category from all repositories
173+
echo -e "\n${YELLOW}Analyzing commits across all repositories...${NC}"
39174

40-
# Fixes
41-
echo -e "\n${GREEN}Bug Fixes:${NC}"
42-
FIXES=$(git -C "$REPO_PATH" log --format="%h %s" "${FROM_VERSION}..${TO_VERSION}" | grep -E "^[a-f0-9]+ fix:" | sed 's/^[a-f0-9]* fix: //')
175+
# Initialize variables
176+
FEATURES=""
177+
FIXES=""
178+
BREAKING=""
179+
PERF=""
180+
API_CHANGES=""
43181

44-
# Breaking changes
45-
echo -e "\n${GREEN}Breaking Changes:${NC}"
46-
BREAKING=$(git -C "$REPO_PATH" log --format="%h %s" "${FROM_VERSION}..${TO_VERSION}" | grep -iE "^[a-f0-9]+ .*(BREAKING|breaking change)" | sed 's/^[a-f0-9]* //')
182+
# Collect commits from all repositories
183+
for repo in "${ALL_REPOS[@]}"; do
184+
if [ -d "$repo" ]; then
185+
repo_name=$(basename "$repo")
186+
echo -e " Analyzing $repo_name..."
187+
188+
# Features
189+
repo_features=$(get_commits_from_repo "$repo" "^[a-f0-9]+ feat:" | sed "s/^[a-f0-9]* feat: /- [$repo_name] /")
190+
if [ -n "$repo_features" ]; then
191+
FEATURES="$FEATURES$repo_features"$'\n'
192+
fi
193+
194+
# Fixes
195+
repo_fixes=$(get_commits_from_repo "$repo" "^[a-f0-9]+ fix:" | sed "s/^[a-f0-9]* fix: /- [$repo_name] /")
196+
if [ -n "$repo_fixes" ]; then
197+
FIXES="$FIXES$repo_fixes"$'\n'
198+
fi
199+
200+
# Breaking changes
201+
repo_breaking=$(get_commits_from_repo "$repo" "^[a-f0-9]+ .*(BREAKING|breaking change)" | sed "s/^[a-f0-9]* /- [$repo_name] /")
202+
if [ -n "$repo_breaking" ]; then
203+
BREAKING="$BREAKING$repo_breaking"$'\n'
204+
fi
205+
206+
# Performance improvements
207+
repo_perf=$(get_commits_from_repo "$repo" "^[a-f0-9]+ perf:" | sed "s/^[a-f0-9]* perf: /- [$repo_name] /")
208+
if [ -n "$repo_perf" ]; then
209+
PERF="$PERF$repo_perf"$'\n'
210+
fi
211+
212+
# API changes
213+
repo_api=$(get_commits_from_repo "$repo" "(api|endpoint|/write|/query|/ping|/health|/metrics|v1|v2|v3)" | sed "s/^[a-f0-9]* /- [$repo_name] /")
214+
if [ -n "$repo_api" ]; then
215+
API_CHANGES="$API_CHANGES$repo_api"$'\n'
216+
fi
217+
fi
218+
done
47219

48-
# Performance improvements
49-
echo -e "\n${GREEN}Performance:${NC}"
50-
PERF=$(git -C "$REPO_PATH" log --format="%h %s" "${FROM_VERSION}..${TO_VERSION}" | grep -E "^[a-f0-9]+ perf:" | sed 's/^[a-f0-9]* perf: //')
220+
# Analyze API changes in detail
221+
echo -e "\n${YELLOW}Analyzing HTTP API changes...${NC}"
222+
for repo in "${ALL_REPOS[@]}"; do
223+
repo_name=$(basename "$repo")
224+
analyze_api_changes "$repo" "$repo_name"
225+
done
51226

52227
# Generate markdown output
53228
OUTPUT_FILE="release-notes-${TO_VERSION}.md"
@@ -60,16 +235,18 @@ EOF
60235

61236
# Add features
62237
if [ -n "$FEATURES" ]; then
63-
while IFS= read -r line; do
64-
PR=$(extract_pr_number "$line")
65-
# Clean up the commit message
66-
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
67-
if [ -n "$PR" ]; then
68-
echo "- $CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
69-
else
70-
echo "- $CLEAN_LINE" >> "$OUTPUT_FILE"
238+
echo "$FEATURES" | while IFS= read -r line; do
239+
if [ -n "$line" ]; then
240+
PR=$(extract_pr_number "$line")
241+
# Clean up the commit message
242+
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
243+
if [ -n "$PR" ]; then
244+
echo "$CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
245+
else
246+
echo "$CLEAN_LINE" >> "$OUTPUT_FILE"
247+
fi
71248
fi
72-
done <<< "$FEATURES"
249+
done
73250
else
74251
echo "- No new features in this release" >> "$OUTPUT_FILE"
75252
fi
@@ -82,15 +259,17 @@ cat >> "$OUTPUT_FILE" << EOF
82259
EOF
83260

84261
if [ -n "$FIXES" ]; then
85-
while IFS= read -r line; do
86-
PR=$(extract_pr_number "$line")
87-
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
88-
if [ -n "$PR" ]; then
89-
echo "- $CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
90-
else
91-
echo "- $CLEAN_LINE" >> "$OUTPUT_FILE"
262+
echo "$FIXES" | while IFS= read -r line; do
263+
if [ -n "$line" ]; then
264+
PR=$(extract_pr_number "$line")
265+
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
266+
if [ -n "$PR" ]; then
267+
echo "$CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
268+
else
269+
echo "$CLEAN_LINE" >> "$OUTPUT_FILE"
270+
fi
92271
fi
93-
done <<< "$FIXES"
272+
done
94273
else
95274
echo "- No bug fixes in this release" >> "$OUTPUT_FILE"
96275
fi
@@ -102,15 +281,17 @@ if [ -n "$BREAKING" ]; then
102281
### Breaking Changes
103282
104283
EOF
105-
while IFS= read -r line; do
106-
PR=$(extract_pr_number "$line")
107-
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
108-
if [ -n "$PR" ]; then
109-
echo "- $CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
110-
else
111-
echo "- $CLEAN_LINE" >> "$OUTPUT_FILE"
284+
echo "$BREAKING" | while IFS= read -r line; do
285+
if [ -n "$line" ]; then
286+
PR=$(extract_pr_number "$line")
287+
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
288+
if [ -n "$PR" ]; then
289+
echo "$CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
290+
else
291+
echo "$CLEAN_LINE" >> "$OUTPUT_FILE"
292+
fi
112293
fi
113-
done <<< "$BREAKING"
294+
done
114295
fi
115296

116297
# Add performance improvements if any
@@ -120,16 +301,54 @@ if [ -n "$PERF" ]; then
120301
### Performance Improvements
121302
122303
EOF
123-
while IFS= read -r line; do
124-
PR=$(extract_pr_number "$line")
125-
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
126-
if [ -n "$PR" ]; then
127-
echo "- $CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
128-
else
129-
echo "- $CLEAN_LINE" >> "$OUTPUT_FILE"
304+
echo "$PERF" | while IFS= read -r line; do
305+
if [ -n "$line" ]; then
306+
PR=$(extract_pr_number "$line")
307+
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
308+
if [ -n "$PR" ]; then
309+
echo "$CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
310+
else
311+
echo "$CLEAN_LINE" >> "$OUTPUT_FILE"
312+
fi
130313
fi
131-
done <<< "$PERF"
314+
done
132315
fi
133316

317+
# Add HTTP API changes if any
318+
if [ -n "$API_CHANGES" ]; then
319+
cat >> "$OUTPUT_FILE" << EOF
320+
321+
### HTTP API Changes
322+
323+
EOF
324+
echo "$API_CHANGES" | while IFS= read -r line; do
325+
if [ -n "$line" ]; then
326+
PR=$(extract_pr_number "$line")
327+
CLEAN_LINE=$(echo "$line" | sed -E 's/ \(#[0-9]+\)$//')
328+
if [ -n "$PR" ]; then
329+
echo "$CLEAN_LINE ([#$PR](https://github.com/influxdata/influxdb/pull/$PR))" >> "$OUTPUT_FILE"
330+
else
331+
echo "$CLEAN_LINE" >> "$OUTPUT_FILE"
332+
fi
333+
fi
334+
done
335+
fi
336+
337+
# Add API analysis summary
338+
cat >> "$OUTPUT_FILE" << EOF
339+
340+
### API Analysis Summary
341+
342+
The following endpoints may have been affected in this release:
343+
- v1 API endpoints: \`/write\`, \`/query\`, \`/ping\`
344+
- v2 API endpoints: \`/api/v2/write\`, \`/api/v2/query\`
345+
- v3 API endpoints: \`/api/v3/*\`
346+
- System endpoints: \`/health\`, \`/metrics\`
347+
348+
Please review the commit details above and consult the API documentation for specific changes.
349+
350+
EOF
351+
134352
echo -e "\n${GREEN}Release notes generated in: ${OUTPUT_FILE}${NC}"
135-
echo -e "${YELLOW}Please review and edit the generated notes before adding to documentation.${NC}"
353+
echo -e "${YELLOW}Please review and edit the generated notes before adding to documentation.${NC}"
354+
echo -e "${BLUE}API changes have been automatically detected and included.${NC}"

0 commit comments

Comments
 (0)