Skip to content

Instantly share code, notes, and snippets.

@loganlinn
Last active October 12, 2020 20:55
Show Gist options
  • Save loganlinn/3cf2ffce2205470c273620b45ca2c593 to your computer and use it in GitHub Desktop.
Save loganlinn/3cf2ffce2205470c273620b45ca2c593 to your computer and use it in GitHub Desktop.
rules_yq
genrule(
name = "yq_binary",
cmd = "cp $< $@",
outs = ["yq"],
srcs = select({
"@bazel_tools//src/conditions:linux_x86_64": ["@yq_linux//file"],
"@bazel_tools//src/conditions:darwin": ["@yq_darwin//file"],
"@bazel_tools//src/conditions:windows": ["@yq_windows//file"],
}),
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
YQ_HTTP_FILES = {
"darwin": dict(
urls = ["https://github.com/mikefarah/yq/releases/download/3.4.0/yq_darwin_amd64"],
sha256 = "f93a7772c9686713fb62066cf96a045ff3dc827575174b261a7ccd9d39a014fe",
),
"linux": dict(
urls = ["https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64"],
sha256 = "f6bd1536a743ab170b35c94ed4c7c4479763356bd543af5d391122f4af852460",
),
"windows": dict(
urls = ["https://github.com/mikefarah/yq/releases/download/3.4.0/yq_windows_amd64.exe"],
sha256 = "298484971d58f4966b10b223f66b329d88bb20e8194e903ed2a847ae887bcdad",
),
}
def yq_repositories():
"""Workspace repository declarations for the `yq` tool."""
for platform, http_file_args in YQ_HTTP_FILES.items():
maybe(
http_file,
name = "yq_{}".format(platform),
executable = True,
downloaded_file_path = "yq",
**http_file_args
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment