Skip to content

Commit aac8d1a

Browse files
authored
Merge pull request #6847 from vie-serendipity/feat/cherry-pick-script
feat: support get release notes from parent pr
2 parents f8c59e4 + 0f83fd3 commit aac8d1a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hack/cherry_pick_pull.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function return_to_kansas {
134134
trap return_to_kansas EXIT
135135

136136
SUBJECTS=()
137+
RELEASE_NOTES=()
137138
function make-a-pr() {
138139
local rel
139140
rel="$(basename "${BRANCH}")"
@@ -142,12 +143,17 @@ function make-a-pr() {
142143

143144
local numandtitle
144145
numandtitle=$(printf '%s\n' "${SUBJECTS[@]}")
146+
local release_notes
147+
if ((${#RELEASE_NOTES[@]} > 0)); then
148+
release_notes=$(printf '%s\n' "${RELEASE_NOTES[@]}")
149+
fi
145150
prtext=$(
146151
cat <<EOF
147152
Cherry pick of ${PULLSUBJ} on ${rel}.
148153
${numandtitle}
149154
For details on the cherry pick process, see the [cherry pick requests](https://karmada.io/docs/contributor/cherry-picks) page.
150155
\`\`\`release-note
156+
${release_notes}
151157
\`\`\`
152158
EOF
153159
)
@@ -196,6 +202,14 @@ for pull in "${PULLS[@]}"; do
196202
subject=$(grep -m 1 "^Subject" "/tmp/${pull}.patch" | sed -e 's/Subject: \[PATCH//g' | sed 's/.*] //')
197203
SUBJECTS+=("#${pull}: ${subject}")
198204

205+
# get release note
206+
echo "+++ Getting release note from PR ${pull}"
207+
pr_body=$(gh pr view "${pull}" --json body --repo "${MAIN_REPO_ORG}/${MAIN_REPO_NAME}" -q '.body')
208+
release_note=$(echo "${pr_body}" | sed -n '/```release-note/,/```/p' | sed '/^```/d' | awk 'NF')
209+
if [[ -n "${release_note}" && "${release_note}" != "NONE" ]]; then
210+
RELEASE_NOTES+=("${release_note}")
211+
fi
212+
199213
# remove the patch file from /tmp
200214
rm -f "/tmp/${pull}.patch"
201215
done

0 commit comments

Comments
 (0)