Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang implementation of release note generating tool #434

Merged
merged 2 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ kubernetes.tar.gz
!\.drone\.sec

/bazel-*

# Golang dependencies
/vendor/
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",
)

51 changes: 51 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/blang/semver"
version = "3.5.1"

[[constraint]]
branch = "master"
name = "github.com/google/go-github"

[[constraint]]
branch = "master"
name = "golang.org/x/oauth2"
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