@@ -14,7 +14,7 @@ info() {
1414}
1515
1616# Check for required commands
17- command -v gh > /dev/null 2>&1 || error " GitHub CLI (gh) is required but not installed"
17+ command -v curl > /dev/null 2>&1 || error " curl is required but not installed"
1818command -v jq > /dev/null 2>&1 || error " jq is required but not installed"
1919
2020# Get inputs
@@ -53,13 +53,28 @@ case "${ARCH}" in
5353 ;;
5454esac
5555
56+ v3_api_call () {
57+ curl -sfL \
58+ -H " Accept: application/vnd.github+json" \
59+ -H " Authorization: Bearer ${GH_TOKEN} " \
60+ -H " X-GitHub-Api-Version: 2022-11-28" \
61+ " https://api.github.com/$1 "
62+ }
63+
64+ download_release () {
65+ local url=" ${1:? download url required} "
66+ local out=" ${2:? asset name required} "
67+ info " Downloading ${url} to ${out} "
68+ curl -sSL -H " Authorization: token ${GH_TOKEN} " -o " ${out} " " ${url} "
69+ }
70+
5671# Get release information using GitHub CLI
57- if [ " ${VERSION} " = " latest" ]; then
58- RELEASE_DATA=$( gh api " repos/${OWNER} /${REPO} /releases/latest" )
72+ if [[ " ${VERSION} " = " latest" ] ]; then
73+ RELEASE_DATA=$( v3_api_call " repos/${OWNER} /${REPO} /releases/latest" )
5974 VERSION=$( jq -r ' .tag_name' <<< " ${RELEASE_DATA}" )
6075 info " Resolved latest version: ${VERSION} "
6176else
62- RELEASE_DATA=$( gh api " repos/${OWNER} /${REPO} /releases/tags/${VERSION} " )
77+ RELEASE_DATA=$( v3_api_call " repos/${OWNER} /${REPO} /releases/tags/${VERSION} " )
6378fi
6479
6580# Create cache directory
@@ -85,23 +100,26 @@ else
85100
86101 # Create temporary directory
87102 TMP_DIR=$( mktemp -d)
88- echo " Temporary directory: ${TMP_DIR} "
103+ info " Temporary directory: ${TMP_DIR} "
89104 cd " ${TMP_DIR} "
90105
91106 # Download and extract asset using gh cli
92107 info " Fetching ${ASSET_NAME} from ${OWNER} /${REPO} #${VERSION} "
93- gh release download " ${VERSION} " -R " ${OWNER} /${REPO} " -p " ${ASSET_NAME} "
108+ DOWNLOAD_URL=$( jq -r --arg asset " ${ASSET_NAME} " ' .assets[] | select(.name == $asset) | .browser_download_url' <<< " ${RELEASE_DATA}" )
109+ download_release " ${DOWNLOAD_URL} " " ${ASSET_NAME} "
94110
95111 if [[ " ${ASSET_NAME} " == * .zip ]]; then
96112 info " Extracting ${ASSET_NAME} "
97113 unzip -q " ${ASSET_NAME} "
98114 elif [[ " ${ASSET_NAME} " == * .tar.gz ]]; then
99115 info " Extracting ${ASSET_NAME} "
116+ tar tzf " ${ASSET_NAME} "
100117 tar xzf " ${ASSET_NAME} "
101118 fi
102119
103120 # Find tool binary
104- TOOL_PATH=$( find . -type f -name " ${TOOL_NAME} *" | grep -Ev ' [.](tar[.]gz|zip)$' | head -n1)
121+ TOOL_PATH=$( find . -type f -name " ${TOOL_NAME} *" -a \! -name " *.[0-9]" | grep -Ev ' [.](tar[.]gz|zip)$' | head -n1)
122+ info " Detected tool binary: ${TOOL_PATH} "
105123 [[ -z " ${TOOL_PATH} " ]] && error " Tool binary '${TOOL_NAME} ' not found in extracted path"
106124
107125 # Copy to cache directory
0 commit comments