1"""Release notes generator""" 2 3def print_rel_notes(*, name, version, archive): 4 native.genrule( 5 name = name, 6 outs = [name + ".txt"], 7 cmd = """ 8 last_rel=$$(curl -s https://api.github.com/repos/bazelbuild/rules_java/releases/latest | grep 'tag_name' | cut -d: -f2 | tr -cd '[:alnum:].') 9 changelog=$$(/usr/bin/git log tags/$$last_rel..origin/master --format=oneline --) 10 sha=$$(/usr/bin/sha256sum $(SRCS) | cut -d ' ' -f1) 11 cat > $@ <<EOF 12**Changes since $$last_rel** 13$$changelog 14 15**MODULE.bazel setup** 16~~~ 17bazel_dep(name = "rules_java", version = "{VERSION}") 18~~~ 19 20**WORKSPACE setup** 21~~~ 22load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 23http_archive( 24 name = "rules_java", 25 urls = [ 26 "https://github.com/bazelbuild/rules_java/releases/download/{VERSION}/rules_java-{VERSION}.tar.gz", 27 ], 28 sha256 = "$$sha", 29) 30 31load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") 32rules_java_dependencies() 33 34# note that the following line is what is minimally required from protobuf for the java rules 35# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl 36load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility 37proto_bazel_features(name = "proto_bazel_features") 38 39# register toolchains 40load("@rules_java//java:repositories.bzl", "rules_java_toolchains") 41rules_java_toolchains() 42~~~ 43 44**Using the rules** 45See [the source](https://github.com/bazelbuild/rules_java/tree/{VERSION}). 46 47EOF 48 """.format(ARCHIVE = archive, VERSION = version), 49 srcs = [archive], 50 tags = ["local", "manual"], 51 ) 52