Skip to content

Commit

Permalink
Add curl version check
Browse files Browse the repository at this point in the history
  • Loading branch information
droopy4096 committed Aug 22, 2023
1 parent 054b3a4 commit 44780b1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ fail() {
exit 1
}

curl_opts=(--fail-with-body -sSL)
version_above(){
local _ver=${1}
local _than_ver=${2}
[ "$_than_ver" = $(echo -e "$_ver\n$_than_ver" | sort -V | head -n1) ]
}

curl_version=$(curl --version | awk 'FNR==1 {print $2}')

if version_above ${curl_version} '7.76.0'; then
curl_opts=(--fail-with-body -sSL)
else
curl_opts=(-fsSL)
fi

if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
Expand Down

0 comments on commit 44780b1

Please sign in to comment.