@@ -22,25 +22,50 @@ export PLATFORM
2222export  SIDECAR_TAG=" ${SIDECAR_IMAGE} :${GIT_TAG} " 
2323export  CONTROLLER_TAG=" ${CONTROLLER_IMAGE} :${GIT_TAG} " 
2424
25- #  build in parallel
2625make 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
3347if  [[ " ${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} " 
3751fi 
3852
39- #  PULL_BASE_REF is 'sidecar/TAG' for a controller  release
53+ #  PULL_BASE_REF is 'sidecar/TAG' for a tagged sidecar  release
4054if  [[ " ${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} " 
4458fi 
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