bazel: fill microservice version on devbuild target (#1994)

* wip: fill microservice version on devbuild

* fill microservice versin on `devbuild`
This commit is contained in:
Moritz Sanft 2023-07-06 08:46:06 +02:00 committed by GitHub
parent e6dbb13c6c
commit c7457bd942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 0 deletions

View File

@ -153,10 +153,13 @@ oci_register_toolchains(
crane_version = LATEST_CRANE_VERSION,
)
load("@aspect_bazel_lib//lib:repositories.bzl", "register_yq_toolchains")
load("//bazel/toolchains:container_images.bzl", "containter_image_deps")
containter_image_deps()
register_yq_toolchains()
# Multirun
load("//bazel/toolchains:multirun_deps.bzl", "multirun_deps")

View File

@ -10,6 +10,7 @@ sh_template(
"//cli:cli_edition_host",
"//debugd/cmd/cdbg:cdbg_host",
"//upgrade-agent/cmd:upgrade_agent_linux_amd64",
"@yq_toolchains//:resolved_toolchain",
],
substitutions = {
"@@BOOTSTRAPPER@@": "$(rootpath //bootstrapper/cmd/bootstrapper:bootstrapper_linux_amd64)",
@ -18,8 +19,10 @@ sh_template(
"@@CONTAINER_SUMS@@": "$(rootpath //bazel/release:container_sums)",
"@@EDITION@@": "$(rootpath :devbuild_cli_edition)",
"@@UPGRADE_AGENT@@": "$(rootpath //upgrade-agent/cmd:upgrade_agent_linux_amd64)",
"@@YQ@@": "$(YQ_BIN)",
},
template = "prepare_developer_workspace.sh.in",
toolchains = ["@yq_toolchains//:resolved_toolchain"],
visibility = ["//visibility:public"],
)

View File

@ -8,6 +8,9 @@
lib=$(realpath @@BASE_LIB@@) || exit 1
stat "${lib}" >> /dev/null || exit 1
yq=$(realpath @@YQ@@)
stat "${yq}" >> /dev/null
# shellcheck source=../sh/lib.bash
if ! source "${lib}"; then
echo "Error: could not find import"
@ -59,3 +62,12 @@ ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${upgrade_agent}")"
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cdbg}")" "${workdir}/cdbg"
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${container_sums}")" "${workdir}/container_sums.sha256"
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cli}")" "${workdir}/constellation"
build_version=$("${workdir}"/constellation version | grep ^Version: | awk '{print $2}')
if [[ ! -f "${workdir}/constellation-conf.yaml" ]]; then
echo "constellation-conf.yaml not present in workspace"
echo "Build version: ${build_version}"
else
$yq -i eval ".microserviceVersion=\"${build_version}\"" ./constellation-conf.yaml
echo "Microservice version updated to ${build_version} in constellation-conf.yaml"
fi

View File

@ -8,6 +8,7 @@ def _sh_template_impl(ctx):
substitutions = {}
for k, v in ctx.attr.substitutions.items():
sub = ctx.expand_location(v, ctx.attr.data)
sub = ctx.expand_make_variables("substitutions", sub, {})
substitutions[k] = sub
ctx.actions.expand_template(
@ -50,6 +51,7 @@ def sh_template(name, **kwargs):
substitutions = kwargs.pop("substitutions", [])
substitutions["@@BASE_LIB@@"] = "$(rootpath //bazel/sh:base_lib)"
template = kwargs.pop("template", [])
toolchains = kwargs.pop("toolchains", [])
_sh_template(
name = script_name,
@ -57,6 +59,7 @@ def sh_template(name, **kwargs):
data = data,
substitutions = substitutions,
template = template,
toolchains = toolchains,
)
native.sh_binary(