Repository: apache/arrow
File: dev/release/02-source.sh (Shell)

Code before:
    --pr-body="PR to verify Release Candidate" \
    --pr-title="WIP: [Release] Verify ${rc_branch}" \
    --remote=https://github.com/${GITHUB_REPOSITORY} \
    --rc=${rc} \
    --verify-source \
    --version=${version}
fi

if [ ${SOURCE_VOTE} -gt 0 ]; then
  curl_common_options=(--header "Authorization: Bearer ${GH_TOKEN}")

  curl_options=("${curl_common_options[@]}")
  curl_options+=(--data "{\"query\": \"query {search(query: \\\"repo:apache/arrow is:issue is:closed milestone:${version}\\\", type:ISSUE) {issueCount}}\"}")
  curl_options+=("https://api.github.com/graphql")
  n_resolved_issues=$(curl "${curl_options[@]}" | jq ".data.search.issueCount")

  curl_options=("${curl_common_options[@]}")
  curl_options+=(--header "Accept: application/vnd.github+json")
  curl_options+=(--get)
  curl_options+=(--data "state=open")
  curl_options+=(--data "head=apache:${rc_branch}")
  curl_options+=(https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls)
  verify_pr_url=$(curl "${curl_options[@]}" | jq -r ".[0].html_url")
  # Read the checksum so we can include it in the vote thread email.
  [[ -f "artifacts/${tarball}.sha512" ]] || { echo "Error: artifacts/${tarball}.sha512 must exist"; exit 1; }
  tarball_hash=$(cat "artifacts/${tarball}.sha512" | awk '{print $1}')

  echo "The following draft email has been created to send to the"
  echo "dev@arrow.apache.org mailing list"
  echo ""
  echo "---------------------------------------------------------"
  cat <<MAIL
To: dev@arrow.apache.org
Subject: [VOTE] Release Apache Arrow ${version} - RC${rc}

Hi,

I would like to propose the following release candidate (RC${rc}) of Apache
Arrow version ${version}. This is a release consisting of ${n_resolved_issues}
resolved GitHub issues[1].

This release candidate is based on commit:
${release_hash} [2]

The source release rc${rc} is hosted at [3].
The binary artifacts are hosted at [4][5][6][7][8][9].
The changelog is located at [10].

Please download, verify checksums and signatures, run the unit tests,
and vote on the release. See [11] for the SHA-512 checksum for this RC and [12]
for how to validate a release candidate.

Review comment (suggestion):
It may be better that we define a variable:

```suggestion
  sha512_path="artifacts/${tarball}.sha512}
  [[ -f "${sha512_path}" ]] || { echo "Error: ${sha512_path} must exist"; exit 1; }
  tarball_hash=$(cat "${sha512_path}" | awk '{print $1}')
```

Code after:
    --pr-body="PR to verify Release Candidate" \
    --pr-title="WIP: [Release] Verify ${rc_branch}" \
    --remote=https://github.com/${GITHUB_REPOSITORY} \
    --rc=${rc} \
    --verify-source \
    --version=${version}
fi

if [ ${SOURCE_VOTE} -gt 0 ]; then
  curl_common_options=(--header "Authorization: Bearer ${GH_TOKEN}")

  curl_options=("${curl_common_options[@]}")
  curl_options+=(--data "{\"query\": \"query {search(query: \\\"repo:apache/arrow is:issue is:closed milestone:${version}\\\", type:ISSUE) {issueCount}}\"}")
  curl_options+=("https://api.github.com/graphql")
  n_resolved_issues=$(curl "${curl_options[@]}" | jq ".data.search.issueCount")

  curl_options=("${curl_common_options[@]}")
  curl_options+=(--header "Accept: application/vnd.github+json")
  curl_options+=(--get)
  curl_options+=(--data "state=open")
  curl_options+=(--data "head=apache:${rc_branch}")
  curl_options+=(https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls)
  verify_pr_url=$(curl "${curl_options[@]}" | jq -r ".[0].html_url")
  # Read the checksum so we can include it in the vote thread email.
  sha512_path="artifacts/${tarball}.sha512"
  [[ -f "${sha512_path}" ]] || { echo "Error: ${sha512_path} must exist"; exit 1; }
  tarball_hash=$(cat "${sha512_path}" | awk '{print $1}')

  echo "The following draft email has been created to send to the"
  echo "dev@arrow.apache.org mailing list"
  echo ""
  echo "---------------------------------------------------------"
  cat <<MAIL
To: dev@arrow.apache.org
Subject: [VOTE] Release Apache Arrow ${version} - RC${rc}

Hi,

I would like to propose the following release candidate (RC${rc}) of Apache
Arrow version ${version}. This is a release consisting of ${n_resolved_issues}
resolved GitHub issues[1].

This release candidate is based on commit:
${release_hash} [2]

The source release rc${rc} is hosted at [3].
The binary artifacts are hosted at [4][5][6][7][8][9].
The changelog is located at [10].

Please download, verify checksums and signatures, run the unit tests,
and vote on the release. See [11] for the SHA-512 checksum for this RC and [12]