Skip to content

Commit 749d692

Browse files
committed
feat: improve GitHub Actions workflows for release automation
- Enhanced create-release-pr.yml: - Fixed version extraction logic for KSP and kotlin-logging dependencies - Added logback version extraction from workload/build.gradle.kts - Improved README and issue template updates using Python script - Better regex patterns for version updates - Enhanced error handling and logging - Enhanced auto-release.yml: - Improved contributor detection and GitHub username extraction - Added GitHub API integration for email-to-username mapping - Implemented caching to avoid duplicate API calls - Better bot user handling (renovate[bot] → @renovate) - Enhanced error handling for API calls - Improved release notes generation with proper contributor mentions - Key improvements: - Automatic logback version updates in README and issue templates - Accurate GitHub username resolution for proper @mentions - Optimized API usage with caching - Better error handling and logging throughout
1 parent b786148 commit 749d692

File tree

2 files changed

+234
-66
lines changed

2 files changed

+234
-66
lines changed

.github/workflows/auto-release.yml

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,82 @@ jobs:
223223
224224
echo "Generating release notes from ${PREVIOUS_TAG} to ${CURRENT_TAG}"
225225
226+
# Cache for GitHub API results to avoid duplicate calls
227+
declare -A EMAIL_TO_USERNAME_CACHE
228+
229+
# Function to get GitHub username from commit author info
230+
get_github_username() {
231+
local author_name="$1"
232+
local author_email="$2"
233+
234+
# Handle bot users - extract bot name from [bot] suffix
235+
if [[ "$author_name" == *"[bot]" ]]; then
236+
echo "${author_name%\[bot\]}"
237+
return
238+
fi
239+
240+
# Handle GitHub noreply emails - extract username from email
241+
if [[ "$author_email" =~ ^([0-9]+\+)?([^@]+)@users\.noreply\.github\.com$ ]]; then
242+
echo "${BASH_REMATCH[2]}"
243+
return
244+
fi
245+
246+
# Handle direct GitHub emails
247+
if [[ "$author_email" =~ ^([^@]+)@github\.com$ ]]; then
248+
echo "${BASH_REMATCH[1]}"
249+
return
250+
fi
251+
252+
# Known mappings for project maintainers (fallback for non-GitHub emails)
253+
case "$author_email" in
254+
"seok9211@naver.com")
255+
echo "doljae"
256+
return
257+
;;
258+
# Add more known mappings here as needed
259+
# "other@example.com")
260+
# echo "other-username"
261+
# return
262+
# ;;
263+
esac
264+
265+
# For non-GitHub emails, use GitHub API to search for user
266+
# Check cache first
267+
if [[ -n "${EMAIL_TO_USERNAME_CACHE[$author_email]}" ]]; then
268+
echo "📋 Using cached result: ${EMAIL_TO_USERNAME_CACHE[$author_email]} for $author_email"
269+
echo "${EMAIL_TO_USERNAME_CACHE[$author_email]}"
270+
return
271+
fi
272+
273+
echo "🔍 Searching GitHub API for email: $author_email"
274+
API_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
275+
"https://api.github.com/search/users?q=${author_email}" 2>/dev/null)
276+
277+
# Check if API call was successful
278+
if [[ $? -ne 0 ]]; then
279+
echo "❌ GitHub API call failed for $author_email"
280+
EMAIL_TO_USERNAME_CACHE[$author_email]="$author_name"
281+
echo "$author_name"
282+
return
283+
fi
284+
285+
USERNAME=$(echo "$API_RESPONSE" | jq -r '.items[0].login // empty' 2>/dev/null)
286+
287+
if [[ -n "$USERNAME" && "$USERNAME" != "null" ]]; then
288+
echo "✅ Found GitHub username: $USERNAME for $author_email"
289+
# Cache the result
290+
EMAIL_TO_USERNAME_CACHE[$author_email]="$USERNAME"
291+
echo "$USERNAME"
292+
return
293+
fi
294+
295+
echo "⚠️ No GitHub username found for $author_email, using author name"
296+
# Cache the fallback result to avoid repeated API calls
297+
EMAIL_TO_USERNAME_CACHE[$author_email]="$author_name"
298+
# Final fallback - use author name (may not work for mentions)
299+
echo "$author_name"
300+
}
301+
226302
# Create release notes
227303
if [ -z "$PREVIOUS_TAG" ] || [ "$PREVIOUS_TAG" = "$CURRENT_TAG" ]; then
228304
# First release or no previous tags
@@ -260,12 +336,13 @@ jobs:
260336
261337
# Track contributors (skip only github-actions bot)
262338
if [[ "$AUTHOR_NAME" != "github-actions[bot]" ]]; then
263-
# Use display name without [bot] suffix for bots
264-
DISPLAY_NAME="$AUTHOR_NAME"
265-
if [[ "$AUTHOR_NAME" == *"[bot]" ]]; then
266-
DISPLAY_NAME="${AUTHOR_NAME%\[bot\]}"
267-
fi
268-
CONTRIBUTORS["$DISPLAY_NAME"]="$AUTHOR_EMAIL"
339+
# Get GitHub username using the simplified function
340+
GITHUB_USERNAME=$(get_github_username "$AUTHOR_NAME" "$AUTHOR_EMAIL")
341+
342+
# Store with GitHub username as key for proper mention
343+
CONTRIBUTORS["$GITHUB_USERNAME"]="$AUTHOR_EMAIL"
344+
345+
echo "📍 Contributor: $AUTHOR_NAME ($AUTHOR_EMAIL) → @$GITHUB_USERNAME"
269346
fi
270347
271348
# Categorize commits
@@ -320,10 +397,15 @@ jobs:
320397
echo "" >> release_notes.md
321398
echo "Thanks to all the contributors who made this release possible:" >> release_notes.md
322399
echo "" >> release_notes.md
323-
for contributor in "${!CONTRIBUTORS[@]}"; do
400+
401+
# Sort contributors alphabetically for consistent output
402+
for contributor in $(printf '%s\n' "${!CONTRIBUTORS[@]}" | sort); do
324403
echo "- @${contributor}" >> release_notes.md
404+
echo " 📍 Added contributor: @${contributor} (${CONTRIBUTORS[$contributor]})"
325405
done
326406
echo "" >> release_notes.md
407+
else
408+
echo "ℹ️ No contributors found for this release"
327409
fi
328410
fi
329411

0 commit comments

Comments
 (0)