Adds tooling/install-godot script that downloads the Godot binary from GitHub releases to ~/bin/godot4. Skips download when the correct version is already installed. Supports Linux x86_64/arm64 and macOS. GODOT_VERSION defaults to 4.6 and is overridable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
109 lines
3.1 KiB
Bash
Executable File
109 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# tooling/install-godot — Download and install Godot to ~/bin/
|
|
#
|
|
# Usage:
|
|
# GODOT_VERSION=4.6 ./tooling/install-godot
|
|
# ./tooling/install-godot # uses default version
|
|
#
|
|
# Installs the Godot binary to ~/bin/godot4.
|
|
# Skips download if correct version is already installed.
|
|
|
|
set -euo pipefail
|
|
|
|
GODOT_VERSION="${GODOT_VERSION:-4.6}"
|
|
INSTALL_DIR="$HOME/bin"
|
|
BINARY="$INSTALL_DIR/godot4"
|
|
|
|
# Check if already installed at the right version
|
|
if [[ -x "$BINARY" ]]; then
|
|
INSTALLED="$("$BINARY" --version 2>/dev/null | head -1 | cut -d. -f1-2)" || true
|
|
if [[ "$INSTALLED" == "$GODOT_VERSION" ]]; then
|
|
echo "Godot $GODOT_VERSION already installed at $BINARY"
|
|
exit 0
|
|
fi
|
|
echo "Godot found but version is $INSTALLED, want $GODOT_VERSION"
|
|
fi
|
|
|
|
# Detect platform and architecture
|
|
OS="$(uname -s)"
|
|
ARCH="$(uname -m)"
|
|
|
|
case "$OS" in
|
|
Linux)
|
|
case "$ARCH" in
|
|
x86_64) PLATFORM="linux.x86_64" ;;
|
|
aarch64) PLATFORM="linux.arm64" ;;
|
|
*) echo "Error: unsupported architecture: $ARCH"; exit 1 ;;
|
|
esac
|
|
;;
|
|
Darwin)
|
|
PLATFORM="macos.universal"
|
|
;;
|
|
*)
|
|
echo "Error: unsupported OS: $OS"
|
|
echo "Install Godot manually: https://godotengine.org/download"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
FILENAME="Godot_v${GODOT_VERSION}-stable_${PLATFORM}.zip"
|
|
URL="https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/${FILENAME}"
|
|
|
|
echo "Downloading Godot $GODOT_VERSION for $PLATFORM..."
|
|
echo " $URL"
|
|
|
|
mkdir -p "$INSTALL_DIR"
|
|
|
|
# Download to temp directory
|
|
TMPDIR="$(mktemp -d)"
|
|
trap 'rm -rf "$TMPDIR"' EXIT
|
|
|
|
if ! curl -fSL --progress-bar -o "$TMPDIR/$FILENAME" "$URL"; then
|
|
echo "Error: download failed. Check GODOT_VERSION=$GODOT_VERSION is a valid release."
|
|
echo "Available releases: https://github.com/godotengine/godot/releases"
|
|
exit 1
|
|
fi
|
|
|
|
# Extract
|
|
echo "Extracting..."
|
|
if ! command -v unzip >/dev/null 2>&1; then
|
|
echo "Error: unzip is required but not found. Install it and retry."
|
|
exit 1
|
|
fi
|
|
unzip -q -o "$TMPDIR/$FILENAME" -d "$TMPDIR/extract"
|
|
|
|
# Install binary
|
|
case "$OS" in
|
|
Linux)
|
|
SRC="$TMPDIR/extract/Godot_v${GODOT_VERSION}-stable_${PLATFORM}"
|
|
if [[ -f "$SRC" ]]; then
|
|
chmod +x "$SRC"
|
|
mv "$SRC" "$BINARY"
|
|
else
|
|
echo "Error: expected binary not found after extraction"
|
|
ls -la "$TMPDIR/extract/"
|
|
exit 1
|
|
fi
|
|
;;
|
|
Darwin)
|
|
SRC="$TMPDIR/extract/Godot.app/Contents/MacOS/Godot"
|
|
if [[ -f "$SRC" ]]; then
|
|
mv "$SRC" "$BINARY"
|
|
chmod +x "$BINARY"
|
|
else
|
|
echo "Error: expected Godot.app binary not found after extraction"
|
|
ls -la "$TMPDIR/extract/"
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
# Verify
|
|
if "$BINARY" --version >/dev/null 2>&1; then
|
|
echo "Godot $GODOT_VERSION installed to $BINARY"
|
|
"$BINARY" --version
|
|
else
|
|
echo "Warning: installed to $BINARY but --version check failed."
|
|
echo "This may be a display server issue (expected in headless environments)."
|
|
fi
|