From 8effb5074821608b840cb43cf8c0a09b8151abbf Mon Sep 17 00:00:00 2001 From: Miral Gadani Date: Mon, 15 May 2023 17:21:49 +0000 Subject: [PATCH] scripts: download latest roachprod binary --- scripts/roachprod-get-latest.sh | 49 +++++++++++++++++++++++++++++++++ scripts/roachprod-update.sh | 2 -- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 scripts/roachprod-get-latest.sh delete mode 100644 scripts/roachprod-update.sh diff --git a/scripts/roachprod-get-latest.sh b/scripts/roachprod-get-latest.sh new file mode 100755 index 000000000000..f395da3ed3d5 --- /dev/null +++ b/scripts/roachprod-get-latest.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +#Downloads the latest roachprod binary from teamcity to the specified directory +# or the current directory if none is specified. +# This does NOT use the TeamCity REST API, but rather a direct download link for the latest successful build +# for the current platform. + +TC_BASE="https://teamcity.cockroachdb.com/repository/download" +TC_ARTIFACT_PATH="latest.lastSuccessful/bazel-bin/pkg/cmd/roachprod/roachprod_/roachprod" + +OS=$(uname | tr '[:upper:]' '[:lower:]') +ARCH=$(arch | tr '[:upper:]' '[:lower:]') + +dest_dir=${1:-.} +dest_file="$dest_dir/roachprod" + +build_for_plat() { + plat="$OS-$ARCH" + if [ "$plat" = "linux-aarch64" ]; then + echo "Cockroach_UnitTests_BazelBuildLinuxArmCross" + elif [ "$plat" = "linux-x86_64" ]; then + echo "Cockroach_ScratchProjectPutTcExperimentsInHere_BazelBuild" + elif [ "$plat" = "darwin-arm64" ]; then + echo "Cockroach_Ci_Builds_BuildMacOSArm64" + elif [ "$plat" = "darwin-x86_64" ]; then + echo "Cockroach_UnitTests_BazelBuildMacOSCross" + else + echo "No build for $PLAT" + exit 1 + fi +} + +prompt_to_overwrite() { + read -p "File already exists. Overwrite? [y/N] " -n 1 -r + echo + [[ $REPLY =~ ^[Yy]$ ]] +} + +build=$(build_for_plat) +URL="$TC_BASE/$build/$TC_ARTIFACT_PATH" +echo "Download URL: $URL" +if command -v curl &> /dev/null; then + if [[ ! -f "$dest_file" ]] || prompt_to_overwrite; then + curl -L -o "$dest_file" -# -u guest: "$URL" + chmod +x "$dest_file" + fi +else + echo "curl is not installed. roachprod can be manually downloaded" +fi diff --git a/scripts/roachprod-update.sh b/scripts/roachprod-update.sh deleted file mode 100644 index 20d602bdd370..000000000000 --- a/scripts/roachprod-update.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -