Skip to content

Commit

Permalink
Move make.sh to .ci
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMock committed Apr 29, 2024
1 parent 66887dd commit 5031819
Showing 1 changed file with 93 additions and 93 deletions.
186 changes: 93 additions & 93 deletions .buildkite/make.sh → .ci/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Build entry script for elasticsearch-serverless-js
#
# Must be called: ./.buildkite/make.sh <target> <params>
# Must be called: ./.ci/make.sh <target> <params>
#
# Version: 1.1.0
#
Expand Down Expand Up @@ -46,83 +46,83 @@ echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"

case $CMD in
clean)
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
rm -rf "$output_folder"
echo -e "\033[32;1mdone.\033[0m"
exit 0
;;
assemble)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: assemble artifact $VERSION\033[0m"
TASK=release
TASK_ARGS=("$VERSION" "$output_folder")
;;
codegen)
if [ -v "$VERSION" ] || [[ -z "$VERSION" ]]; then
# fall back to branch name or `main` if no VERSION is set
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [[ "$branch_name" =~ ^[0-9]+\.[0-9]+ ]]; then
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using branch name: \`$branch_name\`\033[0m"
VERSION="$branch_name"
else
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using \`main\`\033[0m"
VERSION="main"
fi
fi
if [ "$VERSION" = 'main' ]; then
echo -e "\033[36;1mTARGET: codegen API $VERSION\033[0m"
else
echo -e "\033[36;1mTARGET: codegen API v$VERSION\033[0m"
fi

TASK=codegen
TASK_ARGS=("$VERSION")
;;
docsgen)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: docsgen -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m"
TASK=codegen
TASK_ARGS=("$VERSION" "$codegen_folder")
;;
examplesgen)
echo -e "\033[36;1mTARGET: generate examples\033[0m"
TASK=codegen
TASK_ARGS=("$VERSION" "$codegen_folder")
;;
bump)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
TASK=bump
TASK_ARGS=("$VERSION")
;;
bumpmatrix)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: bumpmatrix -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: bump stack in test matrix to version $VERSION\033[0m"
TASK=bumpmatrix
TASK_ARGS=("$VERSION")
;;
*)
echo -e "\n'$CMD' is not supported right now\n"
echo -e "\nUsage:"
echo -e "\t $0 release \$VERSION\n"
echo -e "\t $0 bump \$VERSION"
echo -e "\t $0 codegen \$VERSION"
exit 1
esac
clean)
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
rm -rf "$output_folder"
echo -e "\033[32;1mdone.\033[0m"
exit 0
;;
assemble)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: assemble artifact $VERSION\033[0m"
TASK=release
TASK_ARGS=("$VERSION" "$output_folder")
;;
codegen)
if [ -v "$VERSION" ] || [[ -z "$VERSION" ]]; then
# fall back to branch name or `main` if no VERSION is set
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [[ "$branch_name" =~ ^[0-9]+\.[0-9]+ ]]; then
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using branch name: \`$branch_name\`\033[0m"
VERSION="$branch_name"
else
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using \`main\`\033[0m"
VERSION="main"
fi
fi
if [ "$VERSION" = 'main' ]; then
echo -e "\033[36;1mTARGET: codegen API $VERSION\033[0m"
else
echo -e "\033[36;1mTARGET: codegen API v$VERSION\033[0m"
fi

TASK=codegen
TASK_ARGS=("$VERSION")
;;
docsgen)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: docsgen -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m"
TASK=codegen
TASK_ARGS=("$VERSION" "$codegen_folder")
;;
examplesgen)
echo -e "\033[36;1mTARGET: generate examples\033[0m"
TASK=codegen
TASK_ARGS=("$VERSION" "$codegen_folder")
;;
bump)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
TASK=bump
TASK_ARGS=("$VERSION")
;;
bumpmatrix)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: bumpmatrix -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: bump stack in test matrix to version $VERSION\033[0m"
TASK=bumpmatrix
TASK_ARGS=("$VERSION")
;;
*)
echo -e "\n'$CMD' is not supported right now\n"
echo -e "\nUsage:"
echo -e "\t $0 release \$VERSION\n"
echo -e "\t $0 bump \$VERSION"
echo -e "\t $0 codegen \$VERSION"
exit 1
;;
esac

# ------------------------------------------------------- #
# Build Container
Expand Down Expand Up @@ -179,36 +179,36 @@ fi
# ------------------------------------------------------- #

if [[ "$CMD" == "assemble" ]]; then
if compgen -G ".buildkite/output/*" > /dev/null; then
echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m"
else
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
exit 1
fi
if compgen -G ".buildkite/output/*" >/dev/null; then
echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m"
else
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
exit 1
fi
fi

if [[ "$CMD" == "bump" ]]; then
if [ -n "$(git status --porcelain)" ]; then
echo -e "\033[32;1mTARGET: successfully bumped client v$VERSION\033[0m"
else
echo -e "\033[31;1mTARGET: failed bumped client v$VERSION\033[0m"
if [ -n "$(git status --porcelain)" ]; then
echo -e "\033[32;1mTARGET: successfully bumped client v$VERSION\033[0m"
else
echo -e "\033[31;1mTARGET: failed bumped client v$VERSION\033[0m"
exit 1
fi
fi

if [[ "$CMD" == "codegen" ]]; then
if [ -n "$(git status --porcelain)" ]; then
echo -e "\033[32;1mTARGET: successfully generated client v$VERSION\033[0m"
else
echo -e "\033[31;1mTARGET: failed generating client v$VERSION\033[0m"
if [ -n "$(git status --porcelain)" ]; then
echo -e "\033[32;1mTARGET: successfully generated client v$VERSION\033[0m"
else
echo -e "\033[31;1mTARGET: failed generating client v$VERSION\033[0m"
exit 1
fi
fi

if [[ "$CMD" == "docsgen" ]]; then
echo "TODO"
echo "TODO"
fi

if [[ "$CMD" == "examplesgen" ]]; then
echo "TODO"
echo "TODO"
fi

0 comments on commit 5031819

Please sign in to comment.