bazel-lib/.github/workflows/release_prep.sh

73 lines
1.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
# Configuration for 'git archive'
# see https://git-scm.com/docs/git-archive/2.40.0#ATTRIBUTES
cat >.git/info/attributes <<EOF
# Omit folders that users don't need, making the distribution artifact smaller
lib/tests export-ignore
# Substitution for the _VERSION_PRIVATE placeholder
tools/version.bzl export-subst
EOF
# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="bazel-lib-${TAG:1}"
ARCHIVE="bazel-lib-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
cat << EOF
2022-12-04 17:42:52 +00:00
## Using Bzlmod with Bazel 6:
2022-12-04 17:42:52 +00:00
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
2022-06-06 18:56:40 +00:00
2. Add to your \`MODULE.bazel\` file:
2022-06-06 18:56:04 +00:00
\`\`\`starlark
bazel_dep(name = "aspect_bazel_lib", version = "${TAG:1}")
2022-06-06 18:56:04 +00:00
\`\`\`
> 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/releases/download/${TAG}/${ARCHIVE}",
)
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
aspect_bazel_lib_dependencies()
2022-04-22 17:37:43 +00:00
\`\`\`
Optional toolchains:
\`\`\`starlark
# Register the following toolchain to use jq
2021-12-18 00:41:59 +00:00
load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains")
register_jq_toolchains()
2022-04-22 17:37:43 +00:00
# Register the following toolchain to use yq
load("@aspect_bazel_lib//lib:repositories.bzl", "register_yq_toolchains")
register_yq_toolchains()
\`\`\`
EOF