Created
March 12, 2020 10:53
-
-
Save joernhees/65e862b5432187e454fb95c0010e355a to your computer and use it in GitHub Desktop.
small script to prepare release notes / changelog from github milestones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# adapted from https://gist.github.com/joelittlejohn/5937573 | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: ./generate-changelog.sh user/repo <username>" | |
exit 1 | |
fi | |
# read -s -p "@$2 password: " PASS | |
# echo "" | |
# read only public repo token | |
PASS="XXX" | |
IFS=$'\n' | |
echo "# Changelog" | |
# curl -s "https://$2:[email protected]/repos/$1/milestones?state=closed" | |
# curl -s "https://$2:[email protected]/repos/$1/milestones?state=all" | |
# curl -s "https://$2:[email protected]/repos/$1/milestones" # defaults to open only | |
for m in $(curl -s "https://$2:[email protected]/repos/$1/milestones?state=all" | jq -c '.[] | [.title, .number]' | gsort -rV); do | |
echo -e "\nProcessing milestone: $m..." | |
echo $m | gsed 's/\["\(.*\)",.*\]/\n## \1/' | |
mid=$(echo $m | gsed 's/.*,\(.*\)]/\1/') | |
# curl -s "https://$2:[email protected]/repos/$1/issues?milestone=$mid&state=closed" | |
for page in 1 2 ; do | |
for i in $(curl -s "https://$2:[email protected]/repos/$1/issues?milestone=$mid&state=closed&per_page=100&page=$page" | jq -c '.[] | [.html_url, .number, .title]'); do | |
echo $i | gsed 's/\["\(.*\)",\(.*\),\"\(.*\)\"\]/* \3\n [#\2](\1)/' | gsed 's/\\"/"/g' | |
done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to work with this, just generate a personal access token (see https://github.com/settings/tokens , you don't need to tick any of the boxes, so it can only access public stuff) and replace the
XXX
above.