Skip to content

Commit 9bddc42

Browse files
committed
Add release-type parameter to also handle beta releases
Signed-off-by: Tobias Giese <[email protected]>
1 parent 128914b commit 9bddc42

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

docs/release/release-tasks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ The goal of this task is to keep the CAPI community updated on recent PRs that h
367367
RELEASE_TAG=v1.6.x make release-notes
368368
```
369369
370-
If this is a beta or RC release, add the --pre-release-version flag
370+
If this is a beta or RC release:
371371
```bash
372372
make release-notes-tool
373-
./bin/notes --release=${RELEASE_TAG} --pre-release-version > CHANGELOG/${RELEASE_TAG}.md
373+
./bin/notes --release=${RELEASE_TAG} > CHANGELOG/${RELEASE_TAG}.md
374374
```
375375
376376
1. This will generate a new release notes file at `CHANGELOG/<RELEASE_TAG>.md`. Finalize the release notes:

hack/tools/release/notes/main.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ type notesCmdConfig struct {
5252
newTag string
5353
branch string
5454
prefixAreaLabel bool
55-
preReleaseVersion bool
5655
deprecation bool
5756
addKubernetesVersionSupport bool
5857
}
@@ -67,7 +66,6 @@ func readCmdConfig() *notesCmdConfig {
6766
flag.StringVar(&config.newTag, "release", "", "The tag for the new release.")
6867

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

@@ -103,7 +101,7 @@ func (cmd *notesCmd) run() error {
103101
from, to := parseRef(cmd.config.fromRef), parseRef(cmd.config.toRef)
104102

105103
printer := newReleaseNotesPrinter(cmd.config.repo, from.value)
106-
printer.isPreRelease = cmd.config.preReleaseVersion
104+
printer.releaseType = releaseTypeFromNewTag(cmd.config.newTag)
107105
printer.printDeprecation = cmd.config.deprecation
108106
printer.printKubernetesSupport = cmd.config.addKubernetesVersionSupport
109107

@@ -117,6 +115,26 @@ func (cmd *notesCmd) run() error {
117115
return generator.run()
118116
}
119117

118+
func releaseTypeFromNewTag(newTagConfig string) string {
119+
// Error handling can be ignored as the version has been validated in computeConfigDefaults already.
120+
newTag, _ := semver.ParseTolerant(newTagConfig)
121+
122+
// Return early if it is not a pre release.
123+
if len(newTag.Pre) != 2 {
124+
return ""
125+
}
126+
127+
// Only allow RC and beta releases. More types must be defined here.
128+
// If a new type is not defined, no warning banner will be printed.
129+
switch newTag.Pre[0].VersionStr {
130+
case "rc":
131+
return "RELEASE CANDIDATE"
132+
case "beta":
133+
return "BETA RELEASE"
134+
}
135+
return ""
136+
}
137+
120138
func ensureInstalledDependencies() error {
121139
if !commandExists("gh") {
122140
return errors.New("gh GitHub CLI not available. GitHub CLI is required to be present in the PATH. Refer to https://cli.github.com/ for installation")

hack/tools/release/notes/print.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var defaultOutputOrder = []string{
4141
// the right format for the release notes.
4242
type releaseNotesPrinter struct {
4343
outputOrder []string
44-
isPreRelease bool
44+
releaseType string
4545
printKubernetesSupport bool
4646
printDeprecation bool
4747
fromTag string
@@ -75,8 +75,8 @@ func (p *releaseNotesPrinter) print(entries []notesEntry, commitsInRelease int,
7575
}
7676
}
7777

78-
if p.isPreRelease {
79-
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)
78+
if p.releaseType != "" {
79+
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)
8080
}
8181

8282
if p.printKubernetesSupport {

0 commit comments

Comments
 (0)