initial commit

This commit is contained in:
Daniel Carbone
2022-10-18 11:34:54 -05:00
parent 74713f8a5f
commit e54e1bfbea
10 changed files with 554 additions and 1 deletions

113
scripts/unixish.sh Executable file
View File

@@ -0,0 +1,113 @@
#!/usr/bin/env bash
set -e
echo '::group::Prep'
# validate input and prepare some vars
_base_url='https://github.com/stedolan/jq/releases/download'
_os=
_arch=
_bin_name=
_dl_name=
_dl_path=
_dl_url=
case $RUNNER_OS in
Linux)
_os='linux'
;;
macOS)
_os='osx'
;;
*)
echo "Cannot handle OS of type $RUNNER_OS"
echo "Expected one of: [ Linux macOS ]"
exit 1
;;
esac
case $RUNNER_ARCH in
'X86')
_arch='386'
;;
'X64')
_arch='amd64'
;;
'ARM')
_arch='arm'
;;
'ARM64')
_arch='arm64'
;;
*)
echo "Cannot handle arch of type $RUNNER_ARCH"
echo "Expected one of: [ X86 X64 ARM ARM64 ]"
exit 1
;;
esac
# determine binary name
if [[ "${_os}" == "linux" ]]; then
case "${_arch}" in
'386')
_bin_name="jq-linux32"
;;
'amd64')
_bin_name="jq-linux64"
;;
*)
echo "Cannot handle \"$RUNNER_ARCH\" architecture for os \"$RUNNER_OS\""
exit 1
;;
esac
else
case "${_arch}" in
'amd64')
_bin_name="jq-osx-amd64"
;;
*)
echo "Cannot handle \"$RUNNER_ARCH\" architecture for os \"$RUNNER_OS\""
exit 1
;;
esac
fi
_dl_name="${_bin_name}"
_dl_path="$RUNNER_TEMP/${_dl_name}"
_dl_url="${_base_url}/jq-$JQ_VERSION/${_dl_name}"
echo '::endgroup::'
echo '::group::Downloading jq'
echo "Src: ${_dl_url}"
echo "Dst: ${_dl_path}"
wget -O- "${_dl_url}" > "${_dl_path}"
echo '::endgroup::'
echo '::group::Copying to tool cache'
echo "Creating tool cache directory $RUNNER_TOOL_CACHE/jq"
mkdir -p "$RUNNER_TOOL_CACHE/jq"
echo "Installing into tool cache:"
echo "Src: $RUNNER_TEMP/${_bin_name}"
echo "Dst: $RUNNER_TOOL_CACHE/jq/jq"
mv "$RUNNER_TEMP/${_bin_name}" "$RUNNER_TOOL_CACHE/jq/jq"
echo "Adding $RUNNER_TOOL_CACHE/jq to path..."
echo "$RUNNER_TOOL_CACHE/jq" >> $GITHUB_PATH
echo '::endgroup::'

58
scripts/windowsish.ps1 Normal file
View File

@@ -0,0 +1,58 @@
$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..."
Add-Content "$Env:GITHUB_PATH" "$Env:RUNNER_TOOL_CACHE\jq\"
Write-Host "::endgroup::"