75 lines
2.5 KiB
Bash
Executable File
75 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
function get_latest() {
|
|
local repo="${1}"
|
|
echo $(curl -sSL "https://api.github.com/repos/${repo}/releases/latest" | jq -r '.tag_name')
|
|
}
|
|
|
|
function do_install() {
|
|
local name
|
|
name="${1}"
|
|
|
|
local url
|
|
url="${2}"
|
|
|
|
local working
|
|
working=$(mktemp -d)
|
|
|
|
local current
|
|
current=$(pwd)
|
|
|
|
echo "Downloading ${name} from ${url}"
|
|
|
|
if [[ "${url}" == *.tar.gz ]]; then
|
|
curl --fail-with-body -sSLo "${working}/${name}.tar.gz" "${url}"
|
|
cd "${working}"
|
|
tar -xf "${name}.tar.gz"
|
|
elif [[ "${url}" == *.zip ]]; then
|
|
curl --fail-with-body -sSLo "${working}/${name}.zip" "${url}"
|
|
cd "${working}"
|
|
unzip "${name}.zip"
|
|
elif [[ "${url}" == *.rpm ]]; then
|
|
curl --fail-with-body -sSLo "${working}/${name}.rpm" "${url}"
|
|
else
|
|
curl --fail-with-body -sSLo "${working}/${name}" "${url}"
|
|
fi
|
|
|
|
if [[ "${url}" == *.rpm ]]; then
|
|
dnf install --assumeyes "${working}/${name}.rpm"
|
|
else
|
|
mv "${working}/${name}" "/usr/local/bin/${name}"
|
|
chmod +x "/usr/local/bin/${name}"
|
|
fi
|
|
|
|
cd "${current}"
|
|
rm -rf "${working}"
|
|
}
|
|
|
|
doctl=$(get_latest digitalocean/doctl)
|
|
do_install "doctl" "https://github.com/digitalocean/doctl/releases/download/${doctl}/doctl-${doctl:1}-linux-amd64.tar.gz"
|
|
|
|
tflint=$(get_latest terraform-linters/tflint)
|
|
do_install "tflint" "https://github.com/terraform-linters/tflint/releases/download/${tflint}/tflint_linux_amd64.zip"
|
|
|
|
butane=$(get_latest coreos/butane)
|
|
do_install "butane" "https://github.com/coreos/butane/releases/download/${butane}/butane-x86_64-unknown-linux-gnu"
|
|
|
|
act=$(get_latest nektos/act)
|
|
do_install "act" "https://github.com/nektos/act/releases/download/${act}/act_Linux_x86_64.tar.gz"
|
|
|
|
hadolint=$(get_latest hadolint/hadolint)
|
|
do_install "hadolint" "https://github.com/hadolint/hadolint/releases/download/${hadolint}/hadolint-Linux-x86_64"
|
|
|
|
tenv=$(get_latest tofuutils/tenv)
|
|
do_install "tenv" "https://github.com/tofuutils/tenv/releases/download/${tenv}/tenv_${tenv}_amd64.rpm"
|
|
|
|
sops=$(get_latest getsops/sops)
|
|
do_install "sops" "https://github.com/getsops/sops/releases/download/${sops}/sops-${sops:1}-1.x86_64.rpm"
|
|
|
|
cosign=$(get_latest sigstore/cosign)
|
|
do_install cosign "https://github.com/sigstore/cosign/releases/download/${cosign}/cosign-${cosign:1}-1.x86_64.rpm"
|
|
|
|
codium=$(get_latest VSCodium/vscodium)
|
|
do_install codium "https://github.com/VSCodium/vscodium/releases/download/${codium}/codium-${codium}-el8.x86_64.rpm" |