From 64f3c78dc56fd71fd8d5c21976bc817c576d44a1 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 21 Dec 2023 14:25:46 -0600 Subject: [PATCH] Added generations of contributors/sponsors in release notes GitHub makes this kind of difficult, the best route seems to just scrape the undocumented "sponsors_partial" page? Seems like a strange thing to omit from the REST API. At least contributors are relatively easy, thanks to GitHub's email -> username REST API. Though this does result in an unbounded number of REST queries... --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ccc9e05..5239329a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -210,9 +210,60 @@ jobs: --format="format:[\`%h\`](` `https://github.com/$GITHUB_REPOSITORY/commit/%h) %s" \ > changes.txt - echo "CHANGES:" + echo >> changes.txt + cat changes.txt + # find contributors from history/GitHub + - name: create-contributors + run: | + touch contributors_.txt + for email in $( \ + git log "$LFS_PREV_VERSION.." \ + --grep='^Merge' --invert-grep \ + --format="%ae" \ + | sort \ + | uniq ) + do + curl -sS "$GITHUB_API_URL/search/users?q=$email" \ + | jq -r '"@"+.items[0].login' >> contributors_.txt || true + done + + grep '@' contributors_.txt || exit 0 + + # format + echo "### Contributors" >> contributors.txt + echo >> contributors.txt + echo -n "A special thanks to all who proposed PRs: " >> contributors.txt + sed -z -e 's/\n/, /g' -e 's/, $/\n/g' contributors_.txt >> contributors.txt + + cat contributors.txt + + # find sponsors from GitHub + - name: create-sponsors + run: | + [ -n "${{vars.SPONSORS_URL}}" ] || exit 0 + touch sponsors_.txt + for ((i=1;; i++)) + do + # SPONSORS_URL should be something like + # https://github.com/sponsors//sponsors_partial?filter= + curl -sS "${{vars.SPONSORS_URL}}&page=$i" \ + | grep -o '"@[^"]*"' \ + | sed 's/"//g' \ + | grep '@' >> sponsors_.txt || break + done + + grep '@' sponsors_.txt || exit 0 + + # format + echo "### Sponsors" >> sponsors.txt + echo >> sponsors.txt + echo -n "A special thanks to littlefs's sponsors: " >> sponsors.txt + sed -z -e 's/\n/, /g' -e 's/, $/\n/g' sponsors_.txt >> sponsors.txt + + cat sponsors.txt + # create and update major branches (vN and vN-prefix) - name: create-major-branches run: | @@ -242,10 +293,15 @@ jobs: run: | # create release and patch version tag (vN.N.N) # only draft if not a patch release - touch release.txt + echo "### Changes" >> release.txt + echo >> release.txt [ -e table.txt ] && cat table.txt >> release.txt echo >> release.txt [ -e changes.txt ] && cat changes.txt >> release.txt + echo >> release.txt + [ -e contributors.txt ] && cat contributors.txt >> release.txt + echo >> release.txt + [ -e sponsors.txt ] && cat sponsors.txt >> release.txt cat release.txt curl -sS -X POST -H "authorization: token ${{secrets.BOT_TOKEN}}" \