@@ -34,6 +34,16 @@ case "$(uname -m)" in
3434 * ) echo " Error: Unsupported architecture $( uname -m) " >&2 ; exit 1 ;;
3535esac
3636
37+ # Set up authentication for GitHub requests if GITHUB_TOKEN is available
38+ CURL_AUTH=()
39+ WGET_AUTH=()
40+ GIT_REMOTE=" https://github.com/github/copilot-cli"
41+ if [ -n " $GITHUB_TOKEN " ]; then
42+ CURL_AUTH=(-H " Authorization: token $GITHUB_TOKEN " )
43+ WGET_AUTH=(--header=" Authorization: token $GITHUB_TOKEN " )
44+ GIT_REMOTE=" https://x-access-token:${GITHUB_TOKEN} @github.com/github/copilot-cli"
45+ fi
46+
3747# Determine download URL based on VERSION
3848if [ " ${VERSION} " = " latest" ] || [ -z " $VERSION " ]; then
3949 DOWNLOAD_URL=" https://github.com/github/copilot-cli/releases/latest/download/copilot-${PLATFORM} -${ARCH} .tar.gz"
@@ -44,7 +54,7 @@ elif [ "${VERSION}" = "prerelease" ]; then
4454 echo " Error: git is required to install prerelease versions" >&2
4555 exit 1
4656 fi
47- VERSION=" $( git ls-remote --tags https://github.com/github/copilot-cli | tail -1 | awk -F/ ' {print $NF}' ) "
57+ VERSION=" $( git ls-remote --tags " $GIT_REMOTE " | tail -1 | awk -F/ ' {print $NF}' ) "
4858 if [ -z " $VERSION " ]; then
4959 echo " Error: Could not determine prerelease version" >&2
5060 exit 1
@@ -67,9 +77,9 @@ echo "Downloading from: $DOWNLOAD_URL"
6777TMP_DIR=" $( mktemp -d) "
6878TMP_TARBALL=" $TMP_DIR /copilot-${PLATFORM} -${ARCH} .tar.gz"
6979if command -v curl > /dev/null 2>&1 ; then
70- curl -fsSL " $DOWNLOAD_URL " -o " $TMP_TARBALL "
80+ curl -fsSL " ${CURL_AUTH[@]} " " $ DOWNLOAD_URL" -o " $TMP_TARBALL "
7181elif command -v wget > /dev/null 2>&1 ; then
72- wget -qO " $TMP_TARBALL " " $DOWNLOAD_URL "
82+ wget -qO " $TMP_TARBALL " " ${WGET_AUTH[@]} " " $ DOWNLOAD_URL"
7383else
7484 echo " Error: Neither curl nor wget found. Please install one of them."
7585 rm -rf " $TMP_DIR "
8090TMP_CHECKSUMS=" $TMP_DIR /SHA256SUMS.txt"
8191CHECKSUMS_AVAILABLE=false
8292if command -v curl > /dev/null 2>&1 ; then
83- curl -fsSL " $CHECKSUMS_URL " -o " $TMP_CHECKSUMS " 2> /dev/null && CHECKSUMS_AVAILABLE=true
93+ curl -fsSL " ${CURL_AUTH[@]} " " $ CHECKSUMS_URL" -o " $TMP_CHECKSUMS " 2> /dev/null && CHECKSUMS_AVAILABLE=true
8494elif command -v wget > /dev/null 2>&1 ; then
85- wget -qO " $TMP_CHECKSUMS " " $CHECKSUMS_URL " 2> /dev/null && CHECKSUMS_AVAILABLE=true
95+ wget -qO " $TMP_CHECKSUMS " " ${WGET_AUTH[@]} " " $ CHECKSUMS_URL" 2> /dev/null && CHECKSUMS_AVAILABLE=true
8696fi
8797
8898if [ " $CHECKSUMS_AVAILABLE " = true ]; then
0 commit comments