Skip to content

Commit

Permalink
Add release-type parameter to also handle beta releases
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Giese <tobias.giese@mercedes-benz.com>
  • Loading branch information
tobiasgiese committed Mar 27, 2024
1 parent 128914b commit 04f9fce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/release/release-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,10 @@ The goal of this task is to keep the CAPI community updated on recent PRs that h
RELEASE_TAG=v1.6.x make release-notes
```

If this is a beta or RC release, add the --pre-release-version flag
If this is a beta or RC release, add the --release-type to beta or rc
```bash
make release-notes-tool
./bin/notes --release=${RELEASE_TAG} --pre-release-version > CHANGELOG/${RELEASE_TAG}.md
./bin/notes --release=${RELEASE_TAG} --release-type=beta > CHANGELOG/${RELEASE_TAG}.md
```

1. This will generate a new release notes file at `CHANGELOG/<RELEASE_TAG>.md`. Finalize the release notes:
Expand Down
17 changes: 14 additions & 3 deletions hack/tools/release/notes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type notesCmdConfig struct {
toRef string
newTag string
branch string
releaseType string
prefixAreaLabel bool
preReleaseVersion bool
deprecation bool
addKubernetesVersionSupport bool
}
Expand All @@ -65,9 +65,9 @@ func readCmdConfig() *notesCmdConfig {
flag.StringVar(&config.toRef, "to", "", "The ref (tag, branch or commit to stop at. It must be formatted as heads/<branch name> for branches and tags/<tag name> for tags. If not set, it will default to branch.")
flag.StringVar(&config.branch, "branch", "", "The branch to generate the notes from. If not set, it will be calculated from release.")
flag.StringVar(&config.newTag, "release", "", "The tag for the new release.")
flag.StringVar(&config.releaseType, "release-type", "", "Set the type of the release. You can choose between rc or beta. (default empty, which is a normal release)")

flag.BoolVar(&config.prefixAreaLabel, "prefix-area-label", true, "If enabled, will prefix the area label.")
flag.BoolVar(&config.preReleaseVersion, "pre-release-version", false, "If enabled, will add a pre-release warning header. (default false)")
flag.BoolVar(&config.deprecation, "deprecation", true, "If enabled, will add a templated deprecation warning header.")
flag.BoolVar(&config.addKubernetesVersionSupport, "add-kubernetes-version-support", true, "If enabled, will add the Kubernetes version support header.")

Expand Down Expand Up @@ -103,10 +103,21 @@ func (cmd *notesCmd) run() error {
from, to := parseRef(cmd.config.fromRef), parseRef(cmd.config.toRef)

printer := newReleaseNotesPrinter(cmd.config.repo, from.value)
printer.isPreRelease = cmd.config.preReleaseVersion
printer.printDeprecation = cmd.config.deprecation
printer.printKubernetesSupport = cmd.config.addKubernetesVersionSupport

// We only allow the release version to be empty (real release), rc or beta.
if cmd.config.releaseType != "" {
switch cmd.config.releaseType {
case "beta":
printer.releaseType = "BETA RELEASE"
case "rc":
printer.releaseType = "RELEASE CANDIDATE"
default:
return errors.New("only parameters rc and beta are valid")
}
}

generator := newNotesGenerator(
newGithubFromToPRLister(cmd.config.repo, from, to, cmd.config.branch),
newPREntryProcessor(cmd.config.prefixAreaLabel),
Expand Down
6 changes: 3 additions & 3 deletions hack/tools/release/notes/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var defaultOutputOrder = []string{
// the right format for the release notes.
type releaseNotesPrinter struct {
outputOrder []string
isPreRelease bool
releaseType string
printKubernetesSupport bool
printDeprecation bool
fromTag string
Expand Down Expand Up @@ -75,8 +75,8 @@ func (p *releaseNotesPrinter) print(entries []notesEntry, commitsInRelease int,
}
}

if p.isPreRelease {
fmt.Printf("🚨 This is a RELEASE CANDIDATE. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/%s/issues/new).\n", p.repo)
if p.releaseType != "" {
fmt.Printf("🚨 This is a %s. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/%s/issues/new).\n", p.releaseType, p.repo)
}

if p.printKubernetesSupport {
Expand Down

0 comments on commit 04f9fce

Please sign in to comment.