• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2
3set -o errexit -o nounset -o pipefail
4
5# Set by GH actions, see
6# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7readonly TAG=${GITHUB_REF_NAME}
8# The prefix is chosen to match what GitHub generates for source archives.
9# This guarantees that users can easily switch from a released artifact to a source archive
10# with minimal differences in their code (e.g. strip_prefix remains the same)
11readonly PREFIX="rules_cc-${TAG}"
12readonly ARCHIVE="${PREFIX}.tar.gz"
13
14# NB: configuration for 'git archive' is in /.gitattributes
15git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
16SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
17
18# The stdout of this program will be used as the top of the release notes for this release.
19cat << EOF
20## Using bzlmod with Bazel 6 or later:
21
221. [Bazel 6] Add \`common --enable_bzlmod\` to \`.bazelrc\`.
23
242. Add to your \`MODULE.bazel\` file:
25
26\`\`\`starlark
27bazel_dep(name = "rules_cc", version = "${TAG}")
28\`\`\`
29
30## Using WORKSPACE:
31
32\`\`\`starlark
33
34load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
35
36http_archive(
37    name = "rules_cc",
38    sha256 = "${SHA}",
39    strip_prefix = "${PREFIX}",
40    url = "https://github.com/bazelbuild/rules_cc/releases/download/${TAG}/${ARCHIVE}",
41)
42
43\`\`\`
44EOF