Skip to content

Commit

Permalink
scripts: download latest roachprod binary
Browse files Browse the repository at this point in the history
  • Loading branch information
Miral Gadani committed May 22, 2023
1 parent 9a17dc2 commit 8effb50
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
49 changes: 49 additions & 0 deletions scripts/roachprod-get-latest.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions scripts/roachprod-update.sh

This file was deleted.

0 comments on commit 8effb50

Please sign in to comment.