Skip to content
Merged
Show file tree
Hide file tree
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: 26 additions & 22 deletions ci/cloud_build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ set -ex
printenv

usage() {
echo "Usage: $0 [-r]"
echo " -r : Create a prod proprietary cloud release."
echo "Usage: $0 [-p]"
echo " -p : Create a public cloud release."
}

parse_args() {
while test $# -gt 0; do
case "$1" in
-r) RELEASE=true
shift
;;
-p) PUBLIC=true
shift
;;
Expand All @@ -43,23 +39,28 @@ parse_args "$@"

repo_path=$(pwd)

if [[ -z "${TAG_NAME}" ]]; then
image_tag=$(date +%s)
else
image_tag=$(echo "${TAG_NAME}" | awk -F/ '{print $NF}')
release_tag=${TAG_NAME##*/v}

release="true"
if [[ "${release_tag}" == *"-"* ]]; then
release="false"
fi

echo "The image tag is: ${image_tag}"
echo "The image tag is: ${release_tag}"

# We are building the OSS images/YAMLs. In this case, we only want to push the images but not deploy the YAMLs.
if [[ "$PUBLIC" == "true" ]]; then
bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${image_tag}" \
bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \
--//k8s:build_type=public //k8s/cloud:cloud_images_push

bazel build //tools/licenses:all_licenses --action_env=GOOGLE_APPLICATION_CREDENTIALS
all_licenses_opts=("//tools/licenses:all_licenses" "--action_env=GOOGLE_APPLICATION_CREDENTIALS")
all_licenses_path="$(bazel cquery "${all_licenses_opts[@]}" --output starlark --starlark:expr "target.files.to_list()[0].path" 2> /dev/null)"
bazel build "${all_licenses_opts[@]}"

gsutil cp "${repo_path}/bazel-bin/tools/licenses/all_licenses.json" "gs://pixie-dev-public/oss-licenses/${image_tag}.json"
gsutil cp "${repo_path}/bazel-bin/tools/licenses/all_licenses.json" "gs://pixie-dev-public/oss-licenses/latest.json"
gsutil cp "${all_licenses_path}" "gs://pixie-dev-public/oss-licenses/${release_tag}.json"
if [[ "${release}" == "true" ]]; then
gsutil cp "${all_licenses_path}" "gs://pixie-dev-public/oss-licenses/latest.json"
fi

# Write YAMLs + image paths to a tar file to support easy deployment.
mkdir -p "${repo_path}/pixie_cloud/yamls"
Expand All @@ -79,22 +80,25 @@ if [[ "$PUBLIC" == "true" ]]; then

cd "${repo_path}"
tar -czvf "${repo_path}/pixie_cloud.tar.gz" "pixie_cloud"
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/${image_tag}/pixie_cloud.tar.gz"
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/latest/pixie_cloud.tar.gz"
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/${release_tag}/pixie_cloud.tar.gz"
if [[ "${release}" == "true" ]]; then
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/latest/pixie_cloud.tar.gz"
fi

exit 0
fi

bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${image_tag}" \
bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \
--//k8s:build_type=proprietary //k8s/cloud:cloud_images_push

yaml_path="${repo_path}/bazel-bin/k8s/cloud/pixie_staging_cloud.yaml"
# Build prod YAMLs.
if [[ "$RELEASE" == "true" ]]; then
if [[ "${release}" == "true" ]]; then
# Build prod YAMLs.
yaml_path="${repo_path}/bazel-bin/k8s/cloud/pixie_prod_cloud.yaml"
bazel build --config=stamp -c opt --//k8s:image_version="${image_tag}" //k8s/cloud:pixie_prod_cloud
else # Build staging YAMLs.
bazel build --config=stamp -c opt --//k8s:image_version="${image_tag}" //k8s/cloud:pixie_staging_cloud
bazel build --config=stamp -c opt --//k8s:image_version="${release_tag}" //k8s/cloud:pixie_prod_cloud
else
# Build staging YAMLs.
bazel build --config=stamp -c opt --//k8s:image_version="${release_tag}" //k8s/cloud:pixie_staging_cloud
fi

kubectl apply -f "$yaml_path"
5 changes: 3 additions & 2 deletions scripts/create_release_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ check_args() {
exit
fi

if [ "$ARTIFACT_TYPE" != "cli" ] && [ "$ARTIFACT_TYPE" != "vizier" ] && [ "$ARTIFACT_TYPE" != "operator" ]; then
if [ "$ARTIFACT_TYPE" != "cli" ] && [ "$ARTIFACT_TYPE" != "vizier" ] && [ "$ARTIFACT_TYPE" != "operator" ] && [ "$ARTIFACT_TYPE" != "cloud" ]; then
echo "Unsupported artifact type."
exit
fi
Expand All @@ -71,6 +71,7 @@ get_bazel_target() {
cli) BAZEL_TARGET=//src/pixie_cli:px;;
vizier) BAZEL_TARGET=//k8s/vizier:image_bundle;;
operator) BAZEL_TARGET=//k8s/operator:image_bundle;;
cloud) BAZEL_TARGET=//k8s/cloud:image_bundle;;
esac
}

Expand Down Expand Up @@ -202,7 +203,7 @@ git fetch --tags

# Get the latest release tag.
tags=$(git for-each-ref --sort='-*authordate' --format '%(refname:short)' refs/tags \
| grep "release/$ARTIFACT_TYPE" | grep -v "\-")
| grep "release/$ARTIFACT_TYPE/v" | grep -v "\-")

# Get the most recent tag.
prev_tag=$(echo "$tags" | head -1)
Expand Down
61 changes: 0 additions & 61 deletions scripts/deploy_cloud.sh

This file was deleted.