Skip to content

Commit 40dd618

Browse files
authored
Fix release notes harvesting (#5027)
### Changes - Use pagination in release note collection scripts ### Issues #4991
2 parents a29298b + d9dd508 commit 40dd618

File tree

1 file changed

+43
-17
lines changed

1 file changed

+43
-17
lines changed

scripts/buildkite/release/make_changelog.sh

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,54 @@
22

33
set -euo pipefail
44

5-
since_date="$(buildkite-agent meta-data get last-release-date)"
5+
if [ -n "${BUILDKITE:-}" ]; then
6+
since_date="$(buildkite-agent meta-data get last-release-date)"
7+
fi
68

7-
fetch_prs() {
8-
curl --silent \
9-
-H "Accept: application/vnd.github+json" \
10-
-H "Authorization: Bearer $GITHUB_TOKEN" \
11-
-H "X-GitHub-Api-Version: 2022-11-28" \
12-
"https://api.github.com/search/issues?q=repo:cardano-foundation/cardano-wallet+is:pr+is:merged+merged:%3E$since_date"
13-
}
9+
per_page=30
10+
fetch_prs_at_page() {
11+
results=$(curl --silent \
12+
-H "Accept: application/vnd.github+json" \
13+
-H "Authorization: Bearer $GITHUB_TOKEN" \
14+
-H "X-GitHub-Api-Version: 2022-11-28" \
15+
"https://api.github.com/search/issues?q=repo:cardano-foundation/cardano-wallet+is:pr+is:merged+merged:%3E$since_date&per_page=$per_page&page=$1")
16+
echo "$results"
17+
}
1418

15-
prs=$(fetch_prs | jq '.items | map({date:.pull_request.merged_at | split("T")[0], number:.number,title:.title,labels:.labels| map(.name),author:.user.login })')
19+
fetch_prs() {
20+
local page=1
21+
local all_items=""
22+
local retrieved_count=0
23+
while true; do
24+
results=$(fetch_prs_at_page "$page")
25+
new_items=$(jq '.items | map({date:.pull_request.merged_at | split("T")[0], number:.number,title:.title,labels:.labels| map(.name),author:.user.login })' <<<"$results")
26+
all_items=$(jq -s '.[0] + .[1]' <(echo "$all_items") <(echo "$new_items"))
27+
total_count=$(jq '.total_count' <<<"$results")
28+
items_count=$(jq 'length' <<<"$new_items")
29+
retrieved_count=$((retrieved_count + items_count))
30+
if [ "$retrieved_count" -lt "$total_count" ]; then
31+
page=$((page + 1))
32+
else
33+
break
34+
fi
35+
done
36+
echo "$all_items"
37+
}
1638

17-
items=$(jq 'map("\(.date), #\(.number), \(.author), \(.labels | join(", ")), \(.title)")' <<< "$prs")
18-
item_max=$(jq 'length - 1' <<< "$items")
39+
items=$(fetch_prs)
40+
sorted_items=$(jq 'sort_by(.date)' <<<"$items")
41+
string_items=$(jq 'map("\(.date), #\(.number), \(.author), \(.labels | join(", ")), \(.title)")' <<<"$sorted_items")
42+
item_max=$(jq 'length - 1' <<<"$items")
1943

2044
mkdir -p artifacts
2145

46+
rm -f artifacts/changes.md
47+
2248
for i in $(seq 0 "$item_max"); do
23-
item=$(jq -r ".[$i]" <<< "$items")
24-
echo "$item" \
25-
| sed -E 's,\[(ADP\-[0-9]+)\],[\1](https://cardanofoundation.atlassian.net/browse/\1),g' \
26-
| sed -E 's,\[ADP-x+\],,g' \
27-
| sed -E 's,#([0-9]+),[#\1](https://github.com/cardano-foundation/cardano-wallet/pull/\1),g' \
28-
>> artifacts/changes.md
49+
item=$(jq -r ".[$i]" <<<"$string_items")
50+
echo "$item" |
51+
sed -E 's,\[(ADP\-[0-9]+)\],[\1](https://cardanofoundation.atlassian.net/browse/\1),g' |
52+
sed -E 's,\[ADP-x+\],,g' |
53+
sed -E 's,#([0-9]+),[#\1](https://github.com/cardano-foundation/cardano-wallet/pull/\1),g' \
54+
>>artifacts/changes.md
2955
done

0 commit comments

Comments
 (0)