mirror of
https://github.com/bazel-contrib/bazel-lib
synced 2024-11-26 13:30:30 +00:00
60 lines
1.4 KiB
Bash
Executable file
60 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -o errexit -o nounset -o pipefail
|
|
|
|
# Set by GH actions, see
|
|
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
|
TAG=${GITHUB_REF_NAME}
|
|
PREFIX="bazel-lib-${TAG:1}"
|
|
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')
|
|
|
|
cat << EOF
|
|
|
|
## Using Bzlmod:
|
|
|
|
1. Enable with \`--experimental_enable_bzlmod\` in \`.bazelrc\`.
|
|
2. Add to your \`MODULE.bazel\` file:
|
|
|
|
\`\`\`starlark
|
|
bazel_dep(name = "aspect_bazel_lib", version = "${TAG:1}")
|
|
\`\`\`
|
|
|
|
> Read more about bzlmod: <https://blog.aspect.dev/bzlmod>
|
|
|
|
## Using WORKSPACE
|
|
|
|
Paste this snippet into your `WORKSPACE` file:
|
|
|
|
\`\`\`starlark
|
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
|
|
http_archive(
|
|
name = "aspect_bazel_lib",
|
|
sha256 = "${SHA}",
|
|
strip_prefix = "${PREFIX}",
|
|
url = "https://github.com/aspect-build/bazel-lib/archive/refs/tags/${TAG}.tar.gz",
|
|
)
|
|
|
|
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
|
|
|
|
aspect_bazel_lib_dependencies()
|
|
|
|
\`\`\`
|
|
|
|
Optional toolchains:
|
|
|
|
\`\`\`starlark
|
|
# Register the following toolchain to use jq
|
|
|
|
load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains")
|
|
|
|
register_jq_toolchains()
|
|
|
|
# Register the following toolchain to use yq
|
|
|
|
load("@aspect_bazel_lib//lib:repositories.bzl", "register_yq_toolchains")
|
|
|
|
register_yq_toolchains()
|
|
\`\`\`
|
|
EOF
|