[macOS] Implement helper to get GitHub package download URL (#4923)

This commit is contained in:
Dibir Magomedsaygitov
2022-02-07 17:19:09 +03:00
committed by GitHub
parent 5217af8068
commit f747f0983b
4 changed files with 36 additions and 15 deletions

View File

@@ -2,24 +2,23 @@
source ~/utils/utils.sh
echo "Get the latest Stack version..."
StackRelease=$(curl -H "Authorization: token $API_PAT" -s "https://api.github.com/repos/commercialhaskell/stack/releases/latest")
DownloadUrl=$(echo $StackRelease | jq -r '.assets[].browser_download_url | select(contains("osx-x86_64.tar.gz"))' | head -n 1)
StackVersion=$(echo $StackRelease | jq -r '.name' | cut -c2-)
StackArchive="/tmp/stack.tar.gz"
stackDownloadUrl=$(get_github_package_download_url "commercialhaskell" "stack" "contains(\"osx-x86_64.tar.gz\")" "latest" "$API_PAT")
stackVersion=$(echo $stackDownloadUrl | cut -d "/" -f8 | tr -d "v")
stackArchive="/tmp/stack.tar.gz"
echo "Download stack version $StackVersion..."
download_with_retries $DownloadUrl "/tmp" "stack.tar.gz"
echo "Download stack version $stackVersion..."
download_with_retries $stackDownloadUrl "/tmp" "stack.tar.gz"
StackToolcachePath="$AGENT_TOOLSDIRECTORY/stack/$StackVersion"
DestinationPath="$StackToolcachePath/x64"
stackToolcachePath="$AGENT_TOOLSDIRECTORY/stack/$stackVersion"
destinationPath="$stackToolcachePath/x64"
mkdir -p $DestinationPath
mkdir -p $destinationPath
echo "Unzip stack archive..."
tar -xzf $StackArchive -C $DestinationPath --strip 1
tar -xzf $stackArchive -C $destinationPath --strip 1
touch $StackToolcachePath/x64.complete
touch $stackToolcachePath/x64.complete
echo "export PATH="\$PATH":$DestinationPath" >> "$HOME/.bashrc"
echo "export PATH="\$PATH":$destinationPath" >> "$HOME/.bashrc"
invoke_tests "Common" "Stack"