My goal is to create a zip file that has a git commit SHA of the current HEAD in its name using Bazel.
I know there is a technique called Stamping, but I'm having a tough time wrapping my head around how I can use that for what I need.
I already have some code (rule) that creates the zip file that I need:
def go_binary_zip(name):
go_binary(
name = "{}_bin".format(name),
embed = [":go_default_library"],
goarch = "amd64",
goos = "linux",
visibility = ["//visibility:private"],
)
# How do I add the git commit SHA here?
native.genrule(
name = "{}_bin_archive".format(name),
srcs = [":{}_bin".format(name)],
outs = ["{}_bin.zip".format(name)],
cmd = "$(location @bazel_tools//tools/zip:zipper/zipper) c $@ {}=$<".format(name),
tools = ["@bazel_tools//tools/zip:zipper/zipper"],
visibility = ["//visibility:public"],
)