$ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest Write-Host "::group::Prep" # validate input and prepare some vars switch ($Env:RUNNER_ARCH) { "X86" { $_bin_name = "jq-win32.exe" } "X64" { $_bin_name = "jq-win64.exe" } default { Write-Host "Cannot handle arch of type $Env:RUNNER_ARCH" Write-Host "Expected one of: [ X86 X64 ]" exit 1 } } $_base_url = "https://github.com/stedolan/jq/releases/download" $_dl_name = "${_bin_name}" $_dl_path = "$Env:RUNNER_TEMP\${_dl_name}" $_dl_url = "${_base_url}/jq-$Env:JQ_VERSION/${_dl_name}" Write-Host "::endgroup::" # download artifact Write-Host "::group::Downloading jq" Write-Host "Src: ${_dl_url}" Write-Host "Dst: ${_dl_path}" Invoke-WebRequest -Uri "${_dl_url}" -OutFile "${_dl_path}" Write-Host "::endgroup::" # install into tool cache Write-Host "::group::Copying to tool cache" Write-Host "Creating tool cache directory $Env:RUNNER_TOOL_CACHE\jq\" New-Item "$Env:RUNNER_TOOL_CACHE\jq\" -ItemType Directory -Force Write-Host "Installing into tool cache:" Write-Host "Src: $Env:RUNNER_TEMP\${_bin_name}" Write-Host "Dst: $Env:RUNNER_TOOL_CACHE\jq\jq.exe" Move-Item -Force -LiteralPath "$Env:RUNNER_TEMP\${_bin_name}" -Destination "$Env:RUNNER_TOOL_CACHE\jq\jq.exe" Write-Host "Adding $Env:RUNNER_TOOL_CACHE\jq\ to path..." $( "$Env:RUNNER_TOOL_CACHE\jq\" Get-Content "$Env:GITHUB_PATH" -Raw ) | Set-Content "$Env:GITHUB_PATH" Write-Host "::endgroup::"