|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2023 The Bazel Authors. All rights reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -o errexit -o nounset -o pipefail |
| 17 | + |
| 18 | +# Set by GH actions, see |
| 19 | +# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables |
| 20 | +TAG=${GITHUB_REF_NAME} |
| 21 | +# A prefix is added to better match the GitHub generated archives. |
| 22 | +PREFIX="jsonnet-${TAG}" |
| 23 | +ARCHIVE="jsonnet-$TAG.tar.gz" |
| 24 | +git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE |
| 25 | +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') |
| 26 | + |
| 27 | +cat > release_notes.txt << EOF |
| 28 | +### Importing Jsonnet in a project that uses Bazel |
| 29 | +
|
| 30 | +#### Using Bzlmod with Bazel 6 |
| 31 | +
|
| 32 | +Add to your \`MODULE.bazel\` file: |
| 33 | +
|
| 34 | +\`\`\`starlark |
| 35 | +bazel_dep(name = "jsonnet", version = "${TAG}") |
| 36 | +\`\`\` |
| 37 | +
|
| 38 | +#### Using WORKSPACE |
| 39 | +
|
| 40 | +Paste this snippet into your \`WORKSPACE\` file: |
| 41 | +
|
| 42 | +\`\`\`starlark |
| 43 | +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 44 | +
|
| 45 | +http_archive( |
| 46 | + name = "jsonnet", |
| 47 | + sha256 = "${SHA}", |
| 48 | + strip_prefix = "${PREFIX}", |
| 49 | + url = "https://github.com/google/jsonnet/releases/download/${TAG}/jsonnet-${TAG}.tar.gz", |
| 50 | +) |
| 51 | +\`\`\` |
| 52 | +
|
| 53 | +EOF |
0 commit comments