Skip to content

Commit eb720cb

Browse files
authored
feat(ci): use issue numbers instead of PR numbers (#82)
1 parent 5e1cb5b commit eb720cb

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

.github/workflows/generate-changelog.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
echo "Processing commit: $SHA"
5858
5959
# Find the PR associated with this commit
60-
PR_DATA=$(gh pr list --search "$SHA" --state merged --json number,title --limit 1 2>/dev/null || echo "[]")
60+
PR_DATA=$(gh pr list --search "$SHA" --state merged --json number,title,body --limit 1 2>/dev/null || echo "[]")
6161
6262
if [ "$PR_DATA" = "[]" ] || [ -z "$PR_DATA" ]; then
6363
echo " No PR found, skipping"
@@ -66,12 +66,16 @@ jobs:
6666
6767
PR_NUMBER=$(echo "$PR_DATA" | jq -r '.[0].number // empty')
6868
PR_TITLE=$(echo "$PR_DATA" | jq -r '.[0].title // empty')
69+
PR_BODY=$(echo "$PR_DATA" | jq -r '.[0].body // empty')
6970
7071
if [ -z "$PR_NUMBER" ] || [ -z "$PR_TITLE" ]; then
7172
echo " Could not get PR details, skipping"
7273
continue
7374
fi
7475
76+
# Extract linked issue numbers from PR body (Fixes #XX, Closes #XX, Resolves #XX)
77+
ISSUE_NUMS=$(echo "$PR_BODY" | grep -oiE "(fixes|closes|resolves)\s*#[0-9]+" | grep -oE "[0-9]+" | sort -n | uniq || echo "")
78+
7579
# Skip if we've already processed this PR
7680
if [ -n "${PROCESSED_PRS[$PR_NUMBER]}" ]; then
7781
echo " PR #$PR_NUMBER already processed, skipping"
@@ -103,11 +107,21 @@ jobs:
103107
HIGHLIGHTS+=("$RELEASE_NOTE")
104108
fi
105109
106-
# Build entry using PR number and title
107-
ENTRY="- #${PR_NUMBER} - $PR_TITLE"
110+
# Build entry - use issue number(s) if available
111+
if [ -n "$ISSUE_NUMS" ]; then
112+
# Format multiple issues as "(#1, #2)"
113+
ISSUE_LIST=$(echo "$ISSUE_NUMS" | sed 's/^/#/' | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g')
114+
ENTRY="- $PR_TITLE (${ISSUE_LIST})"
115+
# Use first issue number for sorting
116+
SORT_NUM=$(echo "$ISSUE_NUMS" | head -1)
117+
else
118+
ENTRY="- $PR_TITLE"
119+
# Use high number to sort PRs without issues to the end
120+
SORT_NUM="99999"
121+
fi
108122
109-
# Store with PR number prefix for sorting
110-
SORTABLE_ENTRY="${PR_NUMBER}|${ENTRY}"
123+
# Store with sort number prefix for sorting
124+
SORTABLE_ENTRY="${SORT_NUM}|${ENTRY}"
111125
112126
# Categorize by conventional commit prefix in PR title
113127
if echo "$PR_TITLE" | grep -qE "^fix(\(|:)"; then

0 commit comments

Comments
 (0)