Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ generate_ci_workflows:
cd test && go run ci_workflow_gen.go && cd ..

release-notes:
go run ./go/tools/release-notes -from "$(FROM)" -to "$(TO)" -version "$(VERSION)" -summary "$(SUMMARY)"
go run ./go/tools/release-notes --from "$(FROM)" --to "$(TO)" --version "$(VERSION)" --summary "$(SUMMARY)"

install_kubectl_kind:
./tools/get_kubectl_kind.sh
31 changes: 18 additions & 13 deletions go/tools/release-notes/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"log"
"os"
Expand All @@ -30,6 +29,8 @@ import (
"strings"
"sync"
"text/template"

"github.com/spf13/pflag"
)

type (
Expand Down Expand Up @@ -488,36 +489,40 @@ func groupAndStringifyPullRequest(pr []prInfo) (string, error) {
}

func main() {
from := flag.String("from", "", "from sha/tag/branch")
to := flag.String("to", "HEAD", "to sha/tag/branch")
versionName := flag.String("version", "", "name of the version (has to be the following format: v11.0.0)")
summaryFile := flag.String("summary", "", "readme file on which there is a summary of the release")
flag.Parse()
var (
from, versionName, summaryFile string
to = "HEAD"
)
pflag.StringVarP(&from, "from", "f", "", "from sha/tag/branch")
pflag.StringVarP(&to, "to", to, "t", "to sha/tag/branch")
pflag.StringVarP(&versionName, "version", "v", "", "name of the version (has to be the following format: v11.0.0)")
pflag.StringVarP(&summaryFile, "summary", "s", "", "readme file on which there is a summary of the release")
pflag.Parse()

// The -version flag must be of a valid format.
rx := regexp.MustCompile(`v(\d+)\.(\d+)\.(\d+)`)
// There should be 4 sub-matches, input: "v14.0.0", output: ["v14.0.0", "14", "0", "0"].
versionMatch := rx.FindStringSubmatch(*versionName)
versionMatch := rx.FindStringSubmatch(versionName)
if len(versionMatch) != 4 {
log.Fatal("The -version flag must be set using a valid format. Format: 'vX.X.X'.")
log.Fatal("The --version flag must be set using a valid format. Format: 'vX.X.X'.")
}

releaseNotes := releaseNote{
Version: *versionName,
Version: versionName,
VersionUnderscore: fmt.Sprintf("%s_%s_%s", versionMatch[1], versionMatch[2], versionMatch[3]), // v14.0.0 -> 14_0_0, this is used to format filenames.
}

// summary of the release
if *summaryFile != "" {
summary, err := releaseSummary(*summaryFile)
if summaryFile != "" {
summary, err := releaseSummary(summaryFile)
if err != nil {
log.Fatal(err)
}
releaseNotes.Announcement = summary
}

// known issues
knownIssues, err := loadKnownIssues(*versionName)
knownIssues, err := loadKnownIssues(versionName)
if err != nil {
log.Fatal(err)
}
Expand All @@ -528,7 +533,7 @@ func main() {
releaseNotes.KnownIssues = knownIssuesStr

// changelog with pull requests
prs, authorCommits, commits, err := loadMergedPRs(*from, *to)
prs, authorCommits, commits, err := loadMergedPRs(from, to)
if err != nil {
log.Fatal(err)
}
Expand Down