Skip to content

Commit 5d2b24e

Browse files
[releases] Use semantic versioning for cloud releases. (#1305)
Summary: Updates `scripts/create_release_tag.sh` to also work with `cloud` as an artifact type. Updates `ci/cloud_build_release.sh` to only push to `latest` if its not an RC build. Once we create the first semantically versioned release we should land and deploy pixie-io/docs.px.dev#255. Type of change: /kind cleanup Test Plan: Built a cloud RC using these changes (deleted the tag from the repo so that the current docs.px.dev self-hosted instructions still work until this lands). Ran through the self-hosted deploy instructions (including the changes in pixie-io/docs.px.dev#255) and everything worked. Saw the expected version string in the cloud pods: `time="2023-05-08T20:29:31Z" level=info msg="Starting service" service=api-service version=0.1.0-pre-cloud-semver.5+Distribution.2551dc3.20230508201452.1.jenkins` (as an aside: I will fix the jenkins vs github actions BUILT_BY separately). Changelog Message: ```release-note Pixie Cloud now follows semantic versioning for release versioning. The first semantic versioned release of cloud will be `release/cloud/v0.1.0`. ``` Signed-off-by: James Bartlett <jamesbartlett@pixielabs.ai>
1 parent 01c37d3 commit 5d2b24e

3 files changed

Lines changed: 29 additions & 85 deletions

File tree

ci/cloud_build_release.sh

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ set -ex
2020
printenv
2121

2222
usage() {
23-
echo "Usage: $0 [-r]"
24-
echo " -r : Create a prod proprietary cloud release."
23+
echo "Usage: $0 [-p]"
2524
echo " -p : Create a public cloud release."
2625
}
2726

2827
parse_args() {
2928
while test $# -gt 0; do
3029
case "$1" in
31-
-r) RELEASE=true
32-
shift
33-
;;
3430
-p) PUBLIC=true
3531
shift
3632
;;
@@ -43,23 +39,28 @@ parse_args "$@"
4339

4440
repo_path=$(pwd)
4541

46-
if [[ -z "${TAG_NAME}" ]]; then
47-
image_tag=$(date +%s)
48-
else
49-
image_tag=$(echo "${TAG_NAME}" | awk -F/ '{print $NF}')
42+
release_tag=${TAG_NAME##*/v}
43+
44+
release="true"
45+
if [[ "${release_tag}" == *"-"* ]]; then
46+
release="false"
5047
fi
5148

52-
echo "The image tag is: ${image_tag}"
49+
echo "The image tag is: ${release_tag}"
5350

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

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

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

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

8081
cd "${repo_path}"
8182
tar -czvf "${repo_path}/pixie_cloud.tar.gz" "pixie_cloud"
82-
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/${image_tag}/pixie_cloud.tar.gz"
83-
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/latest/pixie_cloud.tar.gz"
83+
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/${release_tag}/pixie_cloud.tar.gz"
84+
if [[ "${release}" == "true" ]]; then
85+
gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/latest/pixie_cloud.tar.gz"
86+
fi
8487

8588
exit 0
8689
fi
8790

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

9194
yaml_path="${repo_path}/bazel-bin/k8s/cloud/pixie_staging_cloud.yaml"
92-
# Build prod YAMLs.
93-
if [[ "$RELEASE" == "true" ]]; then
95+
if [[ "${release}" == "true" ]]; then
96+
# Build prod YAMLs.
9497
yaml_path="${repo_path}/bazel-bin/k8s/cloud/pixie_prod_cloud.yaml"
95-
bazel build --config=stamp -c opt --//k8s:image_version="${image_tag}" //k8s/cloud:pixie_prod_cloud
96-
else # Build staging YAMLs.
97-
bazel build --config=stamp -c opt --//k8s:image_version="${image_tag}" //k8s/cloud:pixie_staging_cloud
98+
bazel build --config=stamp -c opt --//k8s:image_version="${release_tag}" //k8s/cloud:pixie_prod_cloud
99+
else
100+
# Build staging YAMLs.
101+
bazel build --config=stamp -c opt --//k8s:image_version="${release_tag}" //k8s/cloud:pixie_staging_cloud
98102
fi
99103

100104
kubectl apply -f "$yaml_path"

scripts/create_release_tag.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ check_args() {
6060
exit
6161
fi
6262

63-
if [ "$ARTIFACT_TYPE" != "cli" ] && [ "$ARTIFACT_TYPE" != "vizier" ] && [ "$ARTIFACT_TYPE" != "operator" ]; then
63+
if [ "$ARTIFACT_TYPE" != "cli" ] && [ "$ARTIFACT_TYPE" != "vizier" ] && [ "$ARTIFACT_TYPE" != "operator" ] && [ "$ARTIFACT_TYPE" != "cloud" ]; then
6464
echo "Unsupported artifact type."
6565
exit
6666
fi
@@ -71,6 +71,7 @@ get_bazel_target() {
7171
cli) BAZEL_TARGET=//src/pixie_cli:px;;
7272
vizier) BAZEL_TARGET=//k8s/vizier:image_bundle;;
7373
operator) BAZEL_TARGET=//k8s/operator:image_bundle;;
74+
cloud) BAZEL_TARGET=//k8s/cloud:image_bundle;;
7475
esac
7576
}
7677

@@ -202,7 +203,7 @@ git fetch --tags
202203

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

207208
# Get the most recent tag.
208209
prev_tag=$(echo "$tags" | head -1)

scripts/deploy_cloud.sh

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)