From 8fadf661f13adc7ca4adfe57778212159a182bce Mon Sep 17 00:00:00 2001 From: Ellis Tarn Date: Mon, 1 Aug 2022 12:19:12 -0700 Subject: [PATCH] Chore: Add a script to parse community contributors in each release --- hack/github/community-contributors.sh | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 hack/github/community-contributors.sh diff --git a/hack/github/community-contributors.sh b/hack/github/community-contributors.sh new file mode 100755 index 000000000000..2c40b41275ee --- /dev/null +++ b/hack/github/community-contributors.sh @@ -0,0 +1,52 @@ +#!/bin/bash -u + +TOKEN=$(cat $HOME/.git/token) + +RELEASES=$( + curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token $TOKEN" \ + https://api.github.com/repos/aws/karpenter/releases +) +LATEST=$(echo $RELEASES | jq -r ".[0].tag_name") +PREVIOUS=$(echo $RELEASES | jq -r ".[1].tag_name") + +COMMITS=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token $TOKEN" \ + https://api.github.com/repos/aws/karpenter/compare/$PREVIOUS...$LATEST) + +CONTRIBUTIONS=$( + echo $COMMITS | jq -r ' + .commits + | sort_by(.commit.author.date) + | .[].commit + | {author: .author.name, message: (.message | split("\n")[0])} +' | jq -s +) +NUM_CONTRIBUTIONS=$(echo $CONTRIBUTIONS | jq length) + +COMMUNITY_CONTRIBUTIONS=$( + echo $CONTRIBUTIONS | jq -r ' + .[] + | select( + .author != "Ellis Tarn" and + .author != "Suket Sharma" and + .author != "Todd Neal" and + .author != "Nick Tran" and + .author != "Jason Deal" and + .author != "Ryan Maleki" and + .author != "Jonathan Innis" and + .author != "Brandon Wagner" and + .author != "Chris Negus" and + .author != "Jim DeWaard" and + .author != "dependabot[bot]" + ) +' | jq -s +) + +NUM_COMMUNITY_CONTRIBUTIONS=$(echo $COMMUNITY_CONTRIBUTIONS | jq length) + +echo "Comparing $PREVIOUS and $LATEST" +echo "Community members contributed $NUM_COMMUNITY_CONTRIBUTIONS/$NUM_CONTRIBUTIONS ($(awk "BEGIN {print (100*$NUM_COMMUNITY_CONTRIBUTIONS/$NUM_CONTRIBUTIONS)}")%) commits" +echo $COMMUNITY_CONTRIBUTIONS | jq