diff --git a/api/build.sh b/api/build.sh index bd4c35861..668ce537a 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} @@ -59,11 +78,6 @@ function build_api(){ check_prereq build_api $environment echo buil_complete -#IMAGE_TAG=$IMAGE_TAG PUSH_IMAGE=$PUSH_IMAGE DOCKER_REPO=$DOCKER_REPO SIGN_IMAGE=$SIGN_IMAGE SIGN_KEY=$SIGN_KEY bash build_alerts.sh $1 -# -#[[ $environment == "ee" ]] && { -# cp ../ee/api/build_crons.sh . -# IMAGE_TAG=$IMAGE_TAG PUSH_IMAGE=$PUSH_IMAGE DOCKER_REPO=$DOCKER_REPO SIGN_IMAGE=$SIGN_IMAGE SIGN_KEY=$SIGN_KEY bash build_crons.sh $1 -# exit_err $? -# rm build_crons.sh -#} || true +if [[ $PATCH -eq 1 ]]; then + update_helm_release chalice +fi \ No newline at end of file diff --git a/api/build_alerts.sh b/api/build_alerts.sh index b3c738b99..82ea53e00 100644 --- a/api/build_alerts.sh +++ b/api/build_alerts.sh @@ -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,6 @@ function build_alerts(){ check_prereq build_alerts $1 +if [[ $PATCH -eq 1 ]]; then + update_helm_release alerts +fi diff --git a/assist/build.sh b/assist/build.sh index 7a780cc43..04c191f35 100644 --- a/assist/build.sh +++ b/assist/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="_assist" [[ $1 == "ee" ]] && { @@ -44,3 +63,6 @@ function build_api(){ check_prereq build_api $1 +if [[ $PATCH -eq 1 ]]; then + update_helm_release assist +fi \ No newline at end of file diff --git a/sourcemap-reader/build.sh b/sourcemap-reader/build.sh index 3025e05e4..8ea8f6167 100644 --- a/sourcemap-reader/build.sh +++ b/sourcemap-reader/build.sh @@ -13,7 +13,6 @@ image_name="sourcemaps-reader" git_sha=$(git rev-parse --short HEAD) 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,6 @@ function build_api(){ check_prereq build_api $1 echo buil_complete +if [[ $PATCH -eq 1 ]]; then + update_helm_release sourcemapreader +fi \ No newline at end of file