Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions src/changelog/gptchangelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,50 +265,36 @@ runs:
VERSION=$(echo "$LAST_TAG" | sed 's/^v//')
fi

TEMP_COMMITS=$(mktemp)

if [ "$WORKING_DIR" != "." ]; then
git log --oneline "$SINCE".."$LAST_TAG" -- "$WORKING_DIR" > "$TEMP_COMMITS" 2>/dev/null || true
SHAS=$(git log "$SINCE".."$LAST_TAG" --format='%H' -- "$WORKING_DIR" 2>/dev/null)
else
git log --oneline "$SINCE".."$LAST_TAG" > "$TEMP_COMMITS" 2>/dev/null || true
SHAS=$(git log "$SINCE".."$LAST_TAG" --format='%H' 2>/dev/null)
fi

COMMIT_COUNT=$(wc -l < "$TEMP_COMMITS" | tr -d ' ')
COMMIT_COUNT=$(echo "$SHAS" | grep -c . || true)
echo "📊 Found $COMMIT_COUNT commits for $APP_NAME"

if [ "$COMMIT_COUNT" -eq 0 ]; then
echo "⚠️ No commits found for $APP_NAME in range - skipping"
rm -f "$TEMP_COMMITS"
continue
fi

COMMITS_TEXT=$(cat "$TEMP_COMMITS")
rm -f "$TEMP_COMMITS"

if [ "$WORKING_DIR" != "." ]; then
SHAS=$(git log "$SINCE".."$LAST_TAG" --format='%H' -- "$WORKING_DIR" 2>/dev/null)
else
SHAS=$(git log "$SINCE".."$LAST_TAG" --format='%H' 2>/dev/null)
fi

USERNAMES_FILE=$(mktemp)
# Build annotated commit list: "short-hash subject [@author]"
# Each commit carries its author handle so GPT can attribute inline.
COMMITS_ANNOTATED=""
for SHA in $SHAS; do
COMMIT_LINE=$(git log -1 --format='%h %s' "$SHA" 2>/dev/null || true)
LOGIN=$(gh api "repos/${GITHUB_REPOSITORY}/commits/${SHA}" \
--jq '.author.login // empty' 2>/dev/null || true)
if [[ -n "$LOGIN" && "$LOGIN" != *"[bot]" ]]; then
echo "$LOGIN" >> "$USERNAMES_FILE"
COMMITS_ANNOTATED+="${COMMIT_LINE} [@${LOGIN}]"$'\n'
else
COMMITS_ANNOTATED+="${COMMIT_LINE}"$'\n'
fi
done
echo "📝 Annotated commits:"$'\n'"${COMMITS_ANNOTATED}"
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if [ -s "$USERNAMES_FILE" ]; then
CONTRIBUTORS=$(sort -u "$USERNAMES_FILE" | sed 's/^/@/' | tr '\n' ', ' | sed 's/, $//')
else
CONTRIBUTORS=""
fi
rm -f "$USERNAMES_FILE"
echo "👥 Contributors: $CONTRIBUTORS"

PROMPT="Generate a changelog for ${APP_NAME} ONLY. Commits: ${COMMITS_TEXT} --- STRICT RULES: 1) NEVER mention other components - only ${APP_NAME}. 2) Use bullet points. 3) Group by Features, Fixes, Improvements (skip empty sections). 4) No markdown headers. 5) Max 5 bullet points. 6) End with Contributors: ${CONTRIBUTORS}. 7) ALWAYS wrap version references in backticks - this includes tag names (\`v1\`, \`v1.28.8\`, \`v2.0.0-beta.1\`), action refs (\`@v1\`, \`@v1.28.8\`), and any semver-like token. Never emit a bare version."
PROMPT="Generate a changelog for ${APP_NAME} ONLY. Each commit below includes the author handle in brackets. Commits: ${COMMITS_ANNOTATED} --- STRICT RULES: 1) NEVER mention other components - only ${APP_NAME}. 2) Use bullet points. 3) Group by Features, Fixes, Improvements (skip empty sections). 4) No markdown headers. 5) Max 5 bullet points. 6) For each bullet point add the GitHub handle(s) of the author(s) in parentheses at the end, e.g. 'Fix something important (@bedatty)'. If a bullet combines multiple commits, list all unique handles. Omit handles only when none were detected. 7) ALWAYS wrap version references in backticks - this includes tag names (\`v1\`, \`v1.28.8\`, \`v2.0.0-beta.1\`), action refs (\`@v1\`, \`@v1.28.8\`), and any semver-like token. Never emit a bare version."

REQUEST_BODY=$(jq -n \
--arg model "$OPENAI_MODEL" \
Expand Down