Skip to content

Commit

Permalink
Golang implementation of release note generating tool.
Browse files Browse the repository at this point in the history
This is a duplication of the shell script "relnotes". Commits have
been squashed. Original commits can be found at
https://github.com/roycaihw/release/tree/relnotes-dev
  • Loading branch information
roycaihw committed Nov 14, 2017
1 parent 40f5db3 commit a126e88
Show file tree
Hide file tree
Showing 15 changed files with 1,872 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TODO: Remove this default once rules_go is bumped.
# Ref kubernetes/kubernetes#52677
build --incompatible_comprehension_variables_do_not_leak=false
# TODO: remove the following once repo-infra is bumped.
build --incompatible_disallow_set_constructor=false
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "gazelle")

gazelle(
name = "gazelle",
prefix = "k8s.io/release",
external = "vendored",
)

11 changes: 11 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
workspace(name = "io_kubernetes_build")
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.6.0/rules_go-0.6.0.tar.gz",
sha256 = "ba6feabc94a5d205013e70792accb6cce989169476668fbaf98ea9b342e13b59",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()

load("@io_bazel_rules_go//proto:def.bzl", "proto_register_toolchains")
proto_register_toolchains()
27 changes: 27 additions & 0 deletions toolbox/relnotes/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "k8s.io/release/toolbox/relnotes",
visibility = ["//visibility:private"],
deps = [
"//toolbox/util:go_default_library",
"//vendor/github.com/google/go-github/github:go_default_library",
],
)

go_binary(
name = "relnotes",
importpath = "k8s.io/release/toolbox/relnotes",
library = ":go_default_library",
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["main_test.go"],
importpath = "k8s.io/release/toolbox/relnotes",
library = ":go_default_library",
deps = ["//toolbox/util:go_default_library"],
)
45 changes: 45 additions & 0 deletions toolbox/relnotes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Release Notes Collector

This is a Golang implementation of existing release note collector
[relnotes](https://github.com/kubernetes/release/blob/master/relnotes).

Golang requires this repo being placed within $GOPATH, explicitly at
$GOPATH/src/k8s.io/release.

This tool also uses [dep](https://github.com/golang/dep) to manage Golang
dependencies. To install dep, follow the instructions in [dep's Github
page](https://github.com/golang/dep).

**To bulid, run the build script:**

`./build.sh`

**Or do it manually:**

`cd $GOPATH/src/k8s.io/release`

`dep ensure`

`bazel run //:gazelle`

`bazel build toolbox/relnotes:relnotes`

**Some example command gathering release notes for Kubernetes (assume currently in
a kubernetes repo):**

* (On branch release-1.7:)

`../release/bazel-bin/toolbox/relnotes/relnotes --preview --htmlize-md
--html-file /tmp/release-note-html-testfile
--release-tars=_output/release-tars v1.7.0..v1.7.2`

* (On branch release-1.7:)

`../release/bazel-bin/toolbox/relnotes/relnotes --preview --html-file
/tmp/release-note-html-testfile --release-tars=_output/release-tars
v1.7.0..v1.7.0`

* (On branch release-1.6.3:)

`../release/bazel-bin/toolbox/relnotes/relnotes --html-file
/tmp/release-note-html-testfile --full`
16 changes: 16 additions & 0 deletions toolbox/relnotes/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# This is a build script for Golang relnotes (release note collector), see
# README.md for more information.

# At the root directory
cd $GOPATH/src/k8s.io/release

# Run dep to get the dependencies
dep ensure

# Run gazelle to auto-generate BUILD files
bazel run //:gazelle

# Build the program
bazel build toolbox/relnotes:relnotes
Loading

0 comments on commit a126e88

Please sign in to comment.