def METHOD_NAME(ctx):
    chart_yaml = ctx.actions.declare_file(ctx.label.name + "-chart.yaml")
    ctx.actions.expand_template(
        template = ctx.file._chart_yaml_template,
        output = chart_yaml,
        substitutions = {"${name}": ctx.label.name, "${version}": "0.0.1"},
    )
    values_yaml = ctx.actions.declare_file(ctx.label.name + "-values.yaml")
    source_digests = []
    cmds = [
        "cat {} - > {} <<EOF".format(ctx.file.values.path, values_yaml.path),
        "### Generated by app_chart ###",
        "images:",
    ]
    jq_bin = ctx.toolchains["@aspect_bazel_lib//lib:jq_toolchain_type"].jqinfo.bin
    images = ctx.attr.images or {}
    for key, value in images.items():
        key_files = key[DefaultInfo].files
        for file in key_files.to_list():
            image_dir = file
        # keep the leading '/' since helm charts prepend the registry without one
        cmds.append("  {nick}: /{image}@$({jq} -r '.manifests[0].digest' {digest}/index.json)".format(
            nick = value.replace("-", "_"),
            image = value,
            digest = image_dir.path,
            jq = jq_bin.path,
        ))
        source_digests.append(image_dir)
    cmds.append("EOF")
    ctx.actions.run_shell(
        tools = [jq_bin],
        outputs = [values_yaml],
        inputs = ctx.files.values + source_digests,
        command = "\n".join(cmds),
    )
    helm_chart(
        ctx,
        name = ctx.label.name,
        chart = chart_yaml,
        values = values_yaml,
        # TODO(b/72936439): This is currently unused and fixed to 0.0.1.
        version = "0.0.1",
        templates = ctx.files.templates,
        files = ctx.files.files,
        helm = ctx.file._helm,
        out = ctx.outputs.chart,
    )
    return [DefaultInfo(
        runfiles = ctx.runfiles(files = [ctx.outputs.chart]),
        files = depset([ctx.outputs.chart]),
    )]