Files
shell/install/tilt
T
2026-07-10 15:11:51 +08:00

57 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
##makedesc: Install tilt (k8s dev env)
set -eo pipefail
installed() { command -v "$1" >/dev/null 2>&1; }
isMac() { [ "$(uname -s)" = "Darwin" ]; }
install() {
echo
echo "==============================================="
echo "Installing tilt"
echo "==============================================="
echo
mkdir -p ~/install/tilt ~/.local/bin
if isMac; then
if installed brew; then
brew install kubectl tilt-dev/tap/ctlptl tilt-dev/tap/tilt
else
echo "ERROR: Install Homebrew first." >&2
exit 1
fi
else
cd ~/install/tilt
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
cp ./kubectl ~/.local/bin/kubectl
CTLPTL_URL=$(curl -s "https://api.github.com/repos/tilt-dev/ctlptl/releases/latest" \
| jq -r '.assets.[] | select(.name | test("linux.x86_64.tar.gz")).browser_download_url')
curl -fsSL "$CTLPTL_URL" | tar -xz -C ~/.local/bin ctlptl
TILT_URL=$(curl -s "https://api.github.com/repos/tilt-dev/tilt/releases/latest" \
| jq -r '.assets.[] | select(.name | test("linux.x86_64.tar.gz")).browser_download_url')
curl -fsSL "$TILT_URL" | tar -xz -C ~/.local/bin tilt
fi
echo
echo "Finish!"
echo "ctlptl version = $(ctlptl version)"
echo "tilt version = $(tilt version)"
echo "kubectl version:"
kubectl version
echo
}
case "$1" in
*) install ;;
esac