bazel: update bazel container version on //:tidy

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-07-25 15:00:01 +02:00
parent 1d5a8283e0
commit 0ab76a2f95
4 changed files with 55 additions and 2 deletions

View file

@ -434,6 +434,13 @@ repo_command(
command = ":com_github_katexochen_ghh",
)
sh_template(
name = "bazel_container",
data = [],
substitutions = {},
template = "bazel_container.sh.in",
)
multirun(
name = "tidy",
commands = [
@ -446,6 +453,7 @@ multirun(
":terraform_fmt",
":buf_fmt",
":deps_mirror_fix",
":bazel_container",
],
jobs = 1, # execute sequentially
visibility = ["//visibility:public"],

45
bazel/ci/bazel_container.sh.in Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env bash
###### script header ######
lib=$(realpath @@BASE_LIB@@) || exit 1
stat "${lib}" >> /dev/null || exit 1
# shellcheck source=../sh/lib.bash
if ! source "${lib}"; then
echo "Error: could not find import"
exit 1
fi
cd "${BUILD_WORKSPACE_DIRECTORY}"
###### script body ######
bazelVer=$(cat .bazelversion) # has no v prefix
bazelVerContainerfileRegex='(ARG BAZEL_VERSION=)([0-9]+\.[0-9]+\.[0-9]+)'
if [[ ! "$(cat bazel/container/Containerfile)" =~ ${bazelVerContainerfileRegex} ]]; then
echo "Error: no match found in Containerfile"
exit 1
fi
bazelVerContainerfile="${BASH_REMATCH[2]}"
if [[ ${bazelVer} != "${bazelVerContainerfile}" ]]; then
sed -r -i "s/${bazelVerContainerfileRegex}/\\1${bazelVer}/" bazel/container/Containerfile
echo "Containerfile updated, was previously at ${bazelVerContainerfile}"
fi
bazelVerScriptRegex='(containerImage="ghcr.io/edgelesssys/bazel-container:v)([0-9]+\.[0-9]+\.[0-9]+)'
if [[ ! "$(cat bazel/container/container.sh)" =~ ${bazelVerScriptRegex} ]]; then
echo "Error: no match found in container.sh"
exit 1
fi
bazelVerScript="${BASH_REMATCH[2]}"
if [[ ${bazelVer} != "${bazelVerScript}" ]]; then
# bazelVerScriptRegex contains slashes, so use % as delimiter
sed -r -i "s%${bazelVerScriptRegex}%\\1${bazelVer}%" bazel/container/container.sh
echo "container.sh updated, was previously at ${bazelVerScript}"
fi