Skip to content

Commit 68a2b00

Browse files
authored
feat: Extend changelog generation to show release note category and target_group (#48)
1 parent faafb86 commit 68a2b00

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

generate-changelog.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,30 @@ for PR_NUMBER in $PR_COMMITS; do
4949
continue
5050
fi
5151

52-
TITLE=$(echo "$PR_JSON" | jq -r '.title')
53-
URL=$(echo "$PR_JSON" | jq -r '.url')
54-
BODY=$(echo "$PR_JSON" | jq -r '.body')
52+
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title')
53+
PR_URL=$(echo "$PR_JSON" | jq -r '.url')
54+
PR_BODY=$(echo "$PR_JSON" | jq -r '.body')
5555

5656
# Determine type from conventional commit (assumes title like "type(scope): message" or "type: message")
57-
TYPE=$(echo "$TITLE" | grep -oE '^[a-z]+' || echo "feat")
58-
CLEAN_TITLE=$(echo "$TITLE" | sed -E 's/^[a-z]+(\([^)]+\))?(!)?:[[:space:]]+//')
57+
TYPE=$(echo "$PR_TITLE" | grep -oE '^[a-z]+' || echo "feat")
58+
CLEAN_TITLE=$(echo "$PR_TITLE" | sed -E 's/^[a-z]+(\([^)]+\))?(!)?:[[:space:]]+//')
59+
60+
# Extract release note block, this contains the release notes and the release notes headers.
61+
RELEASE_NOTE_BLOCK=$(echo "$PR_BODY" | sed -n '/\*\*Release note\*\*:/,$p' | sed -n '/^```.*$/,/^```$/p')
62+
# Extract release notes body
63+
RELEASE_NOTE=$(echo "$RELEASE_NOTE_BLOCK" | sed '1d;$d' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
5964

60-
# Extract release note block, we only extract the "user" related notes.
61-
RELEASE_NOTE=$(echo "$BODY" | awk '/^```[[:space:]]*(breaking|feature|bugfix|doc|other)[[:space:]]+user[[:space:]]*$/ {flag=1; next} /^```[[:space:]]*$/ {flag=0} flag' | grep -v 'NONE' || true)
6265
# Format entry
63-
ENTRY="- $CLEAN_TITLE [#${PR_NUMBER}](${URL})"
66+
ENTRY="- $CLEAN_TITLE [#${PR_NUMBER}](${PR_URL})"
6467

65-
if [[ -n "$RELEASE_NOTE" ]]; then
66-
ENTRY+=": $RELEASE_NOTE"
67-
else
68+
if [[ -z "$RELEASE_NOTE" || "$RELEASE_NOTE" == "NONE" ]]; then
6869
ENTRY+="."
70+
else
71+
# Extract and format the release note headers.
72+
HEADERS=$(echo "$PR_BODY" | sed -n '/\*\*Release note\*\*:/,$p' | sed -n '/^```.*$/,/^```$/p'| head -n 1 | sed 's/^```//')
73+
FORMATED_HEADERS=$(echo "$HEADERS" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//; s/\s\+/ /g' | sed 's/\(\S\+\)/[\1]/g')
74+
75+
ENTRY="- ${FORMATED_HEADERS} ${CLEAN_TITLE} [#${PR_NUMBER}](${PR_URL}): ${RELEASE_NOTE}"
6976
fi
7077
ENTRY+="\n"
7178

0 commit comments

Comments
 (0)