generate-release-contributors.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash -e
  2. # shellcheck disable=SC2016
  3. # shellcheck disable=SC2086
  4. from_version=$1
  5. to_version=$2
  6. # get the date of the first commit on main that wasn't in the from_version
  7. from=$(git log --reverse --pretty=format:"%cI" $from_version..HEAD | head -1)
  8. # get the last commit on main that was in the to_version
  9. to=$(git merge-base HEAD $to_version | xargs git log -1 --pretty=format:"%cI")
  10. contributors1=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
  11. query($q: String!, $endCursor: String) {
  12. search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
  13. edges {
  14. node {
  15. ... on PullRequest {
  16. author { login }
  17. reviews(first: 100) {
  18. nodes {
  19. author { login }
  20. }
  21. }
  22. comments(first: 100) {
  23. nodes {
  24. author { login }
  25. }
  26. }
  27. closingIssuesReferences(first: 100) {
  28. nodes {
  29. author { login }
  30. }
  31. }
  32. }
  33. }
  34. }
  35. pageInfo {
  36. hasNextPage
  37. endCursor
  38. }
  39. }
  40. }' --jq '.data.search.edges.[].node.author.login,
  41. .data.search.edges.[].node.reviews.nodes.[].author.login,
  42. .data.search.edges.[].node.comments.nodes.[].author.login,
  43. .data.search.edges.[].node.closingIssuesReferences.nodes.[].author.login')
  44. # this query captures authors of issues which have had PRs in the current range reference the issue
  45. # but not necessarily through closingIssuesReferences (e.g. addressing just a part of an issue)
  46. contributors2=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
  47. query($q: String!, $endCursor: String) {
  48. search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
  49. edges {
  50. node {
  51. ... on PullRequest {
  52. body
  53. }
  54. }
  55. }
  56. pageInfo {
  57. hasNextPage
  58. endCursor
  59. }
  60. }
  61. }
  62. ' --jq '.data.search.edges.[].node.body' \
  63. | grep -oE "#[0-9]{4,}|issues/[0-9]{4,}" \
  64. | grep -oE "[0-9]{4,}" \
  65. | xargs -I{} gh issue view {} --json 'author,url' --jq '[.author.login,.url]' \
  66. | grep -v '/pull/' \
  67. | sed 's/^\["//' \
  68. | sed 's/".*//')
  69. echo $contributors1 $contributors2 \
  70. | sed 's/ /\n/g' \
  71. | sort -uf \
  72. | grep -v linux-foundation-easycla \
  73. | grep -v github-actions \
  74. | grep -v dependabot \
  75. | sed 's/^/@/'