diff --git a/cmd/krel/cmd/BUILD.bazel b/cmd/krel/cmd/BUILD.bazel
index deee7bc97a4..ff8a22fd9b6 100644
--- a/cmd/krel/cmd/BUILD.bazel
+++ b/cmd/krel/cmd/BUILD.bazel
@@ -21,6 +21,7 @@ go_library(
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@com_google_cloud_go//storage:go_default_library",
+ "@in_gopkg_russross_blackfriday_v2//:go_default_library",
"@org_golang_x_oauth2//:go_default_library",
],
)
diff --git a/cmd/krel/cmd/changelog.go b/cmd/krel/cmd/changelog.go
index 7a90954bfb4..84e0744ee44 100644
--- a/cmd/krel/cmd/changelog.go
+++ b/cmd/krel/cmd/changelog.go
@@ -24,6 +24,7 @@ import (
"os"
"path/filepath"
"strings"
+ "text/template"
"github.com/blang/semver"
"github.com/google/go-github/v28/github"
@@ -31,6 +32,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/oauth2"
+ "gopkg.in/russross/blackfriday.v2"
"k8s.io/release/pkg/git"
"k8s.io/release/pkg/notes"
@@ -123,8 +125,11 @@ func runChangelog() (err error) {
return err
}
- // TODO: HTML output
- // TODO: Pushing changes
+ if err := writeHTML(version, markdown); err != nil {
+ return err
+ }
+
+ // TODO: Push changes into repo
return nil
}
@@ -259,3 +264,48 @@ func changelogFilename(version string) (string, error) {
func addTocMarkers(toc string) string {
return fmt.Sprintf("%s\n\n%s\n%s\n", tocStart, toc, tocEnd)
}
+
+const htmlTemplate = `
+
+
+
+
+ {{ .Title }}
+
+
+
+ {{ .Content }}
+
+`
+
+func writeHTML(title, markdown string) error {
+ content := blackfriday.Run([]byte(markdown))
+
+ t, err := template.New("html").Parse(htmlTemplate)
+ if err != nil {
+ return err
+ }
+
+ output := bytes.Buffer{}
+ if err := t.Execute(&output, struct {
+ Title, Content string
+ }{title, string(content)}); err != nil {
+ return err
+ }
+
+ outputPath := filepath.Join(
+ changelogOpts.outputDir,
+ fmt.Sprintf("%s.html", title),
+ )
+ logrus.Infof("Writing single HTML to %s", outputPath)
+ return ioutil.WriteFile(outputPath, output.Bytes(), 0o644)
+}
diff --git a/go.mod b/go.mod
index 67ae977e677..7bab046001b 100644
--- a/go.mod
+++ b/go.mod
@@ -13,9 +13,11 @@ require (
github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481
github.com/pkg/errors v0.8.1
github.com/psampaz/go-mod-outdated v0.5.0
+ github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.4.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
+ gopkg.in/russross/blackfriday.v2 v2.0.0
gopkg.in/src-d/go-git.v4 v4.13.1
)
diff --git a/go.sum b/go.sum
index 77eb0b189dd..d620af52ea5 100644
--- a/go.sum
+++ b/go.sum
@@ -288,6 +288,8 @@ github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041 h1:llrF3Fs4018ePo4+G/HV/uQUqEI1HMDjCeOf2V6puPc=
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
+github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
@@ -507,6 +509,8 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/russross/blackfriday.v2 v2.0.0 h1:+FlnIV8DSQnT7NZ43hcVKcdJdzZoeCmJj4Ql8gq5keA=
+gopkg.in/russross/blackfriday.v2 v2.0.0/go.mod h1:6sSBNz/GtOm/pJTuh5UmBK2ZHfmnxGbl2NZg1UliSOI=
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
diff --git a/repos.bzl b/repos.bzl
index d5ff05535bb..1c77a8ce442 100644
--- a/repos.bzl
+++ b/repos.bzl
@@ -1903,3 +1903,19 @@ def go_repositories():
sum = "h1:9gTOkIwVtoDZywvX802SDHokeX4kW1cKnV8ZTVAPkRs=",
version = "v1.2.5",
)
+ go_repository(
+ name = "com_github_shurcool_sanitized_anchor_name",
+ build_file_generation = "on",
+ build_file_proto_mode = "disable",
+ importpath = "github.com/shurcooL/sanitized_anchor_name",
+ sum = "h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=",
+ version = "v1.0.0",
+ )
+ go_repository(
+ name = "in_gopkg_russross_blackfriday_v2",
+ build_file_generation = "on",
+ build_file_proto_mode = "disable",
+ importpath = "gopkg.in/russross/blackfriday.v2",
+ sum = "h1:+FlnIV8DSQnT7NZ43hcVKcdJdzZoeCmJj4Ql8gq5keA=",
+ version = "v2.0.0",
+ )