This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new df24a82259 MINOR: [Release] Support GitHub token in 
download_rc_binaries.py (#44666)
df24a82259 is described below

commit df24a8225999896eb03db280354fbff42dfea0f5
Author: David Li <[email protected]>
AuthorDate: Thu Nov 7 01:44:01 2024 -0500

    MINOR: [Release] Support GitHub token in download_rc_binaries.py (#44666)
    
    ### Rationale for this change
    
    See apache/arrow-adbc#2307. This script is getting rate-limited on GitHub 
Actions.
    
    ### What changes are included in this PR?
    
    Pick up GH_TOKEN if it exists.
    
    ### Are these changes tested?
    
    N/A
    
    ### Are there any user-facing changes?
    
    N/A
    
    Authored-by: David Li <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 dev/release/download_rc_binaries.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/dev/release/download_rc_binaries.py 
b/dev/release/download_rc_binaries.py
index 49203cd454..788d1df0ab 100755
--- a/dev/release/download_rc_binaries.py
+++ b/dev/release/download_rc_binaries.py
@@ -158,17 +158,22 @@ class GitHub(Downloader):
             raise ValueError("--tag is required")
         self._repository = repository
         self._tag = tag
+        # use the same name as the gh CLI
+        self._token = os.environ.get("GH_TOKEN")
 
     def get_file_list(self, prefix, filter=None):
         url = (f"https://api.github.com/repos/{self._repository}/";
                f"releases/tags/{self._tag}")
         print("Fetching release from", url)
+        headers = {
+            "Accept": "application/vnd.github+json",
+        }
+        if self._token:
+            headers["Authorization"] = f"Bearer {self._token}"
         request = urllib.request.Request(
             url,
             method="GET",
-            headers={
-                "Accept": "application/vnd.github+json",
-            },
+            headers=headers,
         )
         raw_response = urllib.request.urlopen(request).read().decode()
         response = json.loads(raw_response)

Reply via email to