generate-release-contributors.sh 2.8 KB

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