| #!/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} |
| # The prefix is chosen to match what GitHub generates for source archives |
| PREFIX="bazel_features-${TAG:1}" |
| ARCHIVE="bazel_features-$TAG.tar.gz" |
| git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE |
| SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') |
| |
| # Add generated API docs to the release, see https://github.com/bazelbuild/bazel-central-registry/issues/5593 |
| docs="$(mktemp -d)"; targets="$(mktemp)" |
| bazel --output_base="$docs" query --output=label --output_file="$targets" 'kind("starlark_doc_extract rule", //...)' |
| bazel --output_base="$docs" build --target_pattern_file="$targets" |
| tar --create --auto-compress \ |
| --directory "$(bazel --output_base="$docs" info bazel-bin)" \ |
| --file "$GITHUB_WORKSPACE/${ARCHIVE%.tar.gz}.docs.tar.gz" . |
| |
| cat << EOF |
| ## Using Bzlmod with Bazel 6 |
| |
| 1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`. |
| 2. Add to your \`MODULE.bazel\` file: |
| |
| \`\`\`starlark |
| bazel_dep(name = "bazel_features", version = "${TAG:1}") |
| \`\`\` |
| |
| ## Using WORKSPACE |
| |
| Paste this snippet into your `WORKSPACE.bazel` file: |
| |
| \`\`\`starlark |
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| http_archive( |
| name = "bazel_features", |
| sha256 = "${SHA}", |
| strip_prefix = "${PREFIX}", |
| url = "https://github.com/bazel-contrib/bazel_features/releases/download/${TAG}/${ARCHIVE}", |
| ) |
| load("@bazel_features//:deps.bzl", "bazel_features_deps") |
| bazel_features_deps() |
| \`\`\` |
| EOF |