Skip to content

Commit

Permalink
Merge pull request #1298 from saschagrunert/release-notes-deps
Browse files Browse the repository at this point in the history
Add dependency report option to krel release-notes
  • Loading branch information
k8s-ci-robot authored May 18, 2020
2 parents 13f0f21 + aa7bdeb commit 44fe53c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 0 additions & 1 deletion cmd/krel/cmd/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ type changelogOptions struct {
var changelogOpts = &changelogOptions{}

const (
nl = "\n"
tocStart = "<!-- BEGIN MUNGE: GENERATED_TOC -->"
tocEnd = "<!-- END MUNGE: GENERATED_TOC -->"
repoChangelogDir = "CHANGELOG"
Expand Down
22 changes: 21 additions & 1 deletion cmd/krel/cmd/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type releaseNotesOptions struct {
draftRepo string
createDraftPR bool
createWebsitePR bool
dependencies bool
outputDir string
Format string
websiteOrg string
Expand Down Expand Up @@ -167,7 +168,14 @@ func init() {
&releaseNotesOpts.Format,
"format",
util.EnvDefault("FORMAT", "markdown"),
"The format for notes output (options: markdown, json)",
"the format for notes output (options: markdown, json)",
)

releaseNotesCmd.PersistentFlags().BoolVar(
&releaseNotesOpts.dependencies,
"dependencies",
true,
"add dependency report",
)

rootCmd.AddCommand(releaseNotesCmd)
Expand Down Expand Up @@ -657,6 +665,18 @@ func releaseNotesFrom(startTag string) (*releaseNotesResult, error) {
)
}

// Add the dependency report if necessary
if releaseNotesOpts.dependencies {
logrus.Info("Generating dependency changes")
deps, err := notes.NewDependencies().Changes(
notesOptions.StartRev, notesOptions.EndRev,
)
if err != nil {
return nil, errors.Wrap(err, "creating dependency report")
}
markdown += strings.Repeat(nl, 2) + deps
}

// Create the JSON
j, err := json.Marshal(releaseNotes)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions cmd/krel/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"k8s.io/release/pkg/log"
)

const (
nl = "\n"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "krel",
Expand Down
1 change: 1 addition & 0 deletions docs/krel/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ krel changelog [flags]
Flags:
--branch string The branch to be used. Will be automatically inherited by the tag if not set.
--bucket string Specify gs bucket to point to in generated notes (default "kubernetes-release")
--dependencies Add dependency report (default true)
-h, --help help for changelog
--html-file string The target html file to be written. If empty, then it will be CHANGELOG-x.y.html in the current path.
--record string Record the API into a directory
Expand Down
3 changes: 2 additions & 1 deletion docs/krel/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Before running `krel release-notes` export your GitHub token to \$GITHUB_TOKEN:
```
--create-draft-pr create the Release Notes Draft PR. --draft-org and --draft-repo must be set along with this option
--create-website-pr generate the Releas Notes to a local fork of relnotes.k8s.io and create a PR. --draft-org and --draft-repo must be set along with this option
--dependencies add dependency report (default true)
--draft-org string a Github organization owner of the fork of k/sig-release where the Release Notes Draft PR will be created
--draft-repo string the name of the fork of k/sig-release, the Release Notes Draft PR will be created from this repository (default "sig-release")
--format string The format for notes output (options: markdown, json) (default "markdown")
Expand Down Expand Up @@ -84,4 +85,4 @@ krel release-notes --tag v1.18.0-alpha.1 --website-org=kubefriend --create-websi

- Make sure [git `author.email`](https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address) matches the address you used to sign the CNCF's CLA.

- If krel was run without forking `kubernetes/sig-release` and `kubernetes-sigs/release-notes`, the commit will be created but pushing to your fork will fail.
- If krel was run without forking `kubernetes/sig-release` and `kubernetes-sigs/release-notes`, the commit will be created but pushing to your fork will fail.

0 comments on commit 44fe53c

Please sign in to comment.