Skip to content
Merged
Changes from all commits
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
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:

permissions:
contents: write # create the tag and the release
pull-requests: read # "Compose release notes" reads merged PRs (list-PRs-for-commit + get-PR);
# without this the default GITHUB_TOKEN gets 403 "Resource not accessible by integration".

jobs:
release:
Expand Down Expand Up @@ -137,16 +139,19 @@ jobs:
# Every PR whose commits land in this range, de-duplicated.
: > /tmp/pr-numbers.txt
for sha in $(git log --format=%H "$RANGE"); do
# `grep '^[0-9]+$'` guards the file against ever holding anything but a bare PR
# number: if a `gh api` call errors (e.g. a 403), its body must never be treated as
# a "PR number" and fed back into a URL. Belt-and-braces with the numeric loop below.
gh api "repos/${{ github.repository }}/commits/$sha/pulls" \
-q '.[].number' 2>/dev/null >> /tmp/pr-numbers.txt || true
-q '.[].number' 2>/dev/null | grep -E '^[0-9]+$' >> /tmp/pr-numbers.txt || true
done
sort -u -n /tmp/pr-numbers.txt -o /tmp/pr-numbers.txt
echo "found $(wc -l < /tmp/pr-numbers.txt) PRs in $RANGE"

# Fetch each PR's title/body/labels, then compose. jq -s folds the stream into an array.
: > /tmp/prs.ndjson
while read -r n; do
[ -n "$n" ] || continue
case "$n" in ''|*[!0-9]*) continue ;; esac # numeric PR numbers only
gh api "repos/${{ github.repository }}/pulls/$n" \
-q '{number:.number,title:.title,body:(.body // ""),labels:[.labels[].name]}' \
>> /tmp/prs.ndjson
Expand Down
Loading