diff --git a/api/build.sh b/api/build.sh index bd4c35861..946dbf3b6 100644 --- a/api/build.sh +++ b/api/build.sh @@ -10,7 +10,7 @@ # Helper function exit_err() { err_code=$1 - if [[ err_code != 0 ]]; then + if [[ $err_code != 0 ]]; then exit $err_code fi } @@ -27,13 +27,32 @@ check_prereq() { return } +[[ $1 == ee ]] && ee=true +[[ $PATCH -eq 1 ]] && { + image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } +} +update_helm_release() { + chart=$1 + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" +} + function build_api(){ destination="_api" [[ $1 == "ee" ]] && { destination="_api_ee" } cp -R ../api ../${destination} - cd ../${destination} + cd ../${destination} || exit_err 100 tag="" # Copy enterprise code [[ $1 == "ee" ]] && { @@ -43,7 +62,7 @@ function build_api(){ } mv Dockerfile.dockerignore .dockerignore docker build -f ./Dockerfile --build-arg envarg=$envarg --build-arg GIT_SHA=$git_sha -t ${DOCKER_REPO:-'local'}/chalice:${image_tag} . - cd ../api + cd ../api || exit_err 100 rm -rf ../${destination} [[ $PUSH_IMAGE -eq 1 ]] && { docker push ${DOCKER_REPO:-'local'}/chalice:${image_tag} @@ -67,3 +86,4 @@ echo buil_complete # exit_err $? # rm build_crons.sh #} || true +[[ $PATCH -eq 1 ]] && update_helm_release chalice diff --git a/api/build_alerts.sh b/api/build_alerts.sh index b3c738b99..5047780fe 100644 --- a/api/build_alerts.sh +++ b/api/build_alerts.sh @@ -8,7 +8,7 @@ # Usage: IMAGE_TAG=latest DOCKER_REPO=myDockerHubID bash build.sh git_sha=$(git rev-parse --short HEAD) -image_tag=${IMAGE_TAG:-git_sha} +image_tag=${IMAGE_TAG:-$git_sha} envarg="default-foss" check_prereq() { which docker || { @@ -17,6 +17,26 @@ check_prereq() { } } + +[[ $1 == ee ]] && ee=true +[[ $PATCH -eq 1 ]] && { + image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } +} +update_helm_release() { + chart=$1 + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" +} + function build_alerts(){ destination="_alerts" [[ $1 == "ee" ]] && { @@ -48,3 +68,4 @@ function build_alerts(){ check_prereq build_alerts $1 +[[ $PATCH -eq 1 ]] && update_helm_release alerts diff --git a/backend/build.sh b/backend/build.sh index 95a833139..5c0b1b771 100755 --- a/backend/build.sh +++ b/backend/build.sh @@ -10,7 +10,7 @@ set -e git_sha=$(git rev-parse --short HEAD) -image_tag=${IMAGE_TAG:-git_sha} +image_tag=${IMAGE_TAG:-$git_sha} ee="false" check_prereq() { which docker || { @@ -20,6 +20,25 @@ check_prereq() { return } +[[ $1 == ee ]] && ee=true +[[ $PATCH -eq 1 ]] && { + image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } +} +update_helm_release() { + chart=$1 + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" +} + function build_service() { image="$1" echo "BUILDING $image" @@ -48,6 +67,7 @@ function build_api(){ } [[ $2 != "" ]] && { build_service $2 + [[ $PATCH -eq 1 ]] && update_helm_release $2 cd ../backend rm -rf ../${destination} return @@ -56,6 +76,7 @@ function build_api(){ do build_service $image echo "::set-output name=image::${DOCKER_REPO:-'local'}/$image:${image_tag}" + [[ $PATCH -eq 1 ]] && update_helm_release $image done cd ../backend rm -rf ../${destination} diff --git a/frontend/build.sh b/frontend/build.sh index 55d295746..ecb2fe845 100644 --- a/frontend/build.sh +++ b/frontend/build.sh @@ -9,8 +9,7 @@ # Usage: IMAGE_TAG=latest DOCKER_REPO=myDockerHubID bash build.sh git_sha=$(git rev-parse --short HEAD) -image_tag=${IMAGE_TAG:-git_sha} -ee="false" +image_tag=${IMAGE_TAG:-$git_sha} check_prereq() { which docker || { echo "Docker not installed, please install docker." @@ -18,6 +17,25 @@ check_prereq() { } } +[[ $1 == ee ]] && ee=true +[[ $PATCH -eq 1 ]] && { + image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } +} +update_helm_release() { + chart=$1 + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" +} + # https://github.com/docker/cli/issues/1134#issuecomment-613516912 export DOCKER_BUILDKIT=1 function build(){ @@ -34,3 +52,4 @@ function build(){ check_prereq build $1 +[[ $PATCH -eq 1 ]] && update_helm_release frontend diff --git a/peers/build.sh b/peers/build.sh index 45cc97892..dfff188cb 100644 --- a/peers/build.sh +++ b/peers/build.sh @@ -15,6 +15,25 @@ check_prereq() { } } +[[ $1 == ee ]] && ee=true +[[ $PATCH -eq 1 ]] && { + image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } +} +update_helm_release() { + chart=$1 + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" +} + function build_api(){ destination="_peers" [[ $1 == "ee" ]] && { @@ -43,3 +62,4 @@ function build_api(){ check_prereq build_api $1 +[[ $PATCH -eq 1 ]] && update_helm_release peers diff --git a/scripts/helmcharts/openreplay/charts/chalice/Chart.yaml b/scripts/helmcharts/openreplay/charts/chalice/Chart.yaml index b64b3b243..ed6a2415a 100644 --- a/scripts/helmcharts/openreplay/charts/chalice/Chart.yaml +++ b/scripts/helmcharts/openreplay/charts/chalice/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.1.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -AppVersion: "v1.10.0" +AppVersion: "v1.10.1" diff --git a/sourcemap-reader/build.sh b/sourcemap-reader/build.sh index fbe8762e2..7169403e7 100644 --- a/sourcemap-reader/build.sh +++ b/sourcemap-reader/build.sh @@ -11,9 +11,8 @@ set -e image_name="sourcemaps-reader" git_sha=$(git rev-parse --short HEAD) -image_tag=${IMAGE_TAG:-git_sha} +image_tag=${IMAGE_TAG:-$git_sha} envarg="default-foss" -tmp_folder_name="${image_name}_${RANDOM}" check_prereq() { which docker || { @@ -23,6 +22,25 @@ check_prereq() { return } +[[ $1 == ee ]] && ee=true +[[ $PATCH -eq 1 ]] && { + image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } +} +update_helm_release() { + chart=$1 + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" +} + function build_api(){ destination="_smr" [[ $1 == "ee" ]] && { @@ -55,3 +73,4 @@ function build_api(){ check_prereq build_api $1 echo buil_complete +[[ $PATCH -eq 1 ]] && update_helm_release sourcemapreader diff --git a/utilities/build.sh b/utilities/build.sh index 87ff7f3e6..861d37596 100644 --- a/utilities/build.sh +++ b/utilities/build.sh @@ -15,6 +15,25 @@ check_prereq() { } } +[[ $1 == ee ]] && ee=true +[[ $PATCH -eq 1 ]] && { + image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } +} +update_helm_release() { + chart=$1 + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" +} + function build_api(){ destination="_utilities" [[ $1 == "ee" ]] && { @@ -44,3 +63,4 @@ function build_api(){ check_prereq build_api $1 +[[ $PATCH -eq 1 ]] && update_helm_release assist