Skip to content

Commit 74c92fa

Browse files
committed
cloudbuild: update tag/release script
As COSI is working to release v0.2.0 from the new monorepo, ensure images are built and released to staging that are useful for devs and vendor drivers dependent on COSI. Keep 'main' and 'latest' tags that follow COSI main head that is useful for COSI devs and driver devs, as well as canary-type CI envs. Keep 'release-*' tags that follow COSI release branches that are useful for CI envs. Allow tagging COSI commits with standard semver tags like 'v0.2.0' that don't include the 'sidecar/' or 'controller/' prefixes. These tags will release both sidecar and controller images to staging while COSI maintainers talk to sig-storage about releasing individual images from monorepos using the standardized sig-storage prow image tooling. Signed-off-by: Blaine Gardner <[email protected]>
1 parent 0cc7472 commit 74c92fa

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

hack/cloudbuild.sh

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,50 @@ export PLATFORM
2222
export SIDECAR_TAG="${SIDECAR_IMAGE}:${GIT_TAG}"
2323
export CONTROLLER_TAG="${CONTROLLER_IMAGE}:${GIT_TAG}"
2424

25-
# build in parallel
2625
make build
2726

28-
# add latest tag to just-built images
29-
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:latest"
30-
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:latest"
27+
# PULL_BASE_REF is 'main' for non-tagged commits on the main branch
28+
if [[ "${PULL_BASE_REF}" == main ]]; then
29+
echo " ! ! ! this is a main branch build ! ! !"
30+
# 'main' tag follows the main branch head
31+
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:main"
32+
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:main"
33+
# 'latest' tag follows 'main' for easy use by developers
34+
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:latest"
35+
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:latest"
36+
fi
37+
38+
# PULL_BASE_REF is 'release-*' for non-tagged commits on release branches
39+
if [[ "${PULL_BASE_REF}" == release-* ]]; then
40+
echo " ! ! ! this is a ${PULL_BASE_REF} release branch build ! ! !"
41+
# 'release-*' tags that follow each release branch head
42+
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:${PULL_BASE_REF}"
43+
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:${PULL_BASE_REF}"
44+
fi
3145

32-
# PULL_BASE_REF is 'controller/TAG' for a controller release
46+
# PULL_BASE_REF is 'controller/TAG' for a tagged controller release
3347
if [[ "${PULL_BASE_REF}" == controller/* ]]; then
3448
echo " ! ! ! this is a tagged controller release ! ! !"
3549
TAG="${PULL_BASE_REF#controller/*}"
3650
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:${TAG}"
3751
fi
3852

39-
# PULL_BASE_REF is 'sidecar/TAG' for a controller release
53+
# PULL_BASE_REF is 'sidecar/TAG' for a tagged sidecar release
4054
if [[ "${PULL_BASE_REF}" == sidecar/* ]]; then
4155
echo " ! ! ! this is a tagged sidecar release ! ! !"
4256
TAG="${PULL_BASE_REF#sidecar/*}"
4357
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:${TAG}"
4458
fi
4559

46-
# else, PULL_BASE_REF is a branch name (e.g., master, release-0.2) or a tag (e.g., client/v0.2.0, proto/v0.2.0)
60+
# PULL_BASE_REF is 'v0.y.z*' for tagged alpha releases where controller and sidecar are released simultaneously
61+
# hand wave over complex matching logic by just looking for 'v0.' prefix
62+
if [[ "${PULL_BASE_REF}" == 'v0.'* ]]; then
63+
echo " ! ! ! this is a tagged controller + sidecar release ! ! !"
64+
TAG="${PULL_BASE_REF}"
65+
gcloud container images add-tag "${CONTROLLER_TAG}" "${CONTROLLER_IMAGE}:${TAG}"
66+
gcloud container images add-tag "${SIDECAR_TAG}" "${SIDECAR_IMAGE}:${TAG}"
67+
fi
68+
69+
# else, PULL_BASE_REF is something that doesn't release image(s) to staging, like:
70+
# - a random branch name (e.g., feature-xyz)
71+
# - a version tag for a subdir with no image associated (e.g., client/v0.2.0, proto/v0.2.0)

0 commit comments

Comments
 (0)