Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions doc/scripts/process-native-protocol-specs-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,43 @@ GO_VERSION="1.23.1"
GO_TAR="go${GO_VERSION}.linux-amd64.tar.gz"
TMPDIR="${TMPDIR:-/tmp}"

# Step 0: Download and install Go
echo "Downloading Go $GO_VERSION..."
wget -q "https://golang.org/dl/$GO_TAR" -O "$TMPDIR/$GO_TAR"

echo "Installing Go..."
tar -C "$TMPDIR" -xzf "$TMPDIR/$GO_TAR"
rm "$TMPDIR/$GO_TAR"

# Set Go environment variables
export PATH="$PATH:$TMPDIR/go/bin"
export GOPATH="$TMPDIR/go"
check_go_version() {
if command -v go &>/dev/null; then
local installed_version=$(go version | awk '{print $3}' | sed 's/go//')

if [ "$(printf '%s\n' "$GO_VERSION" "$installed_version" | sort -V | head -n1)" = "$GO_VERSION" ]; then
echo "Detected Go $installed_version (>= $GO_VERSION), skipping installation."
return 0
else
echo "Detected Go $installed_version (< $GO_VERSION), proceeding with installation."
return 1
fi
else
echo "Go env not found in your system, proceeding with installation."
return 1
fi
}

if ! check_go_version; then
# Step 0: Download and install Go
echo "Downloading Go $GO_VERSION..."
wget --timeout=30 --tries=2 --waitretry=5 -q "https://golang.org/dl/$GO_TAR" -O "$TMPDIR/$GO_TAR"

if [ $? -ne 0 ]; then
echo "Network issue. manually install golang or use -Dant.gen-doc.skip=true to skip it"
exit 1
fi

echo "Installing Go $GO_VERSION..."
tar -C "$TMPDIR" -xzf "$TMPDIR/$GO_TAR"
rm "$TMPDIR/$GO_TAR"

# Set Go environment variables
export PATH="$PATH:$TMPDIR/go/bin"
export GOPATH="$TMPDIR/go"
else
echo "Using system-installed Go."
fi

# Step 1: Building the parser
echo "Building the cqlprotodoc..."
Expand Down