Skip to content

Commit d46e201

Browse files
Merge pull request #1636 from Nordix/tuomo/fix-release-note-generator
🌱 add support for beta/rc releases in release notes
2 parents 4f45b88 + 1ff7cb8 commit d46e201

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions: {}
1010

1111
jobs:
1212
build:
13-
name: release
13+
name: tag release
1414
runs-on: ubuntu-latest
1515

1616
permissions:
@@ -36,4 +36,4 @@ jobs:
3636
with:
3737
draft: true
3838
files: out/*
39-
body_path: releasenotes/releasenotes.md
39+
body_path: releasenotes/${{ env.RELEASE_TAG }}.md

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ mod: ## Clean up go module settings
320320
## Release
321321
## --------------------------------------
322322
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
323-
PREVIOUS_TAG ?= $(shell git tag -l | grep -B 1 "^$(RELEASE_TAG)" | head -n 1)
324323
RELEASE_NOTES_DIR := releasenotes
324+
PREVIOUS_TAG ?= $(shell git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | sort -V | grep -B1 $(RELEASE_TAG) | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | head -n 1 2>/dev/null)
325325

326326
$(RELEASE_NOTES_DIR):
327327
mkdir -p $(RELEASE_NOTES_DIR)/
328328

329329
.PHONY: release-notes
330330
release-notes: $(RELEASE_NOTES_DIR)
331-
go run ./hack/tools/release_notes.go --from=$(PREVIOUS_TAG) > $(RELEASE_NOTES_DIR)/releasenotes.md
331+
go run ./hack/tools/release/notes.go --from=$(PREVIOUS_TAG) > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
332332

333333
go-version: ## Print the go version we use to compile our binaries and images
334334
@echo $(GO_VERSION)

hack/tools/release_notes.go renamed to hack/tools/release/notes.go

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ const (
4545
superseded = ":recycle: Superseded or Reverted"
4646
)
4747

48+
const (
49+
warningTemplate = ":rotating_light: This is a %s. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/metal3-io/baremetal-operator/issues/new/).\n\n"
50+
)
51+
4852
var (
4953
outputOrder = []string{
5054
warning,
@@ -85,6 +89,14 @@ func lastTag() string {
8589
return string(bytes.TrimSpace(out))
8690
}
8791

92+
func isBeta(tag string) bool {
93+
return strings.Contains(tag, "-beta.")
94+
}
95+
96+
func isRC(tag string) bool {
97+
return strings.Contains(tag, "-rc.")
98+
}
99+
88100
func firstCommit() string {
89101
cmd := exec.Command("git", "rev-list", "--max-parents=0", "HEAD")
90102
out, err := cmd.Output()
@@ -97,7 +109,7 @@ func firstCommit() string {
97109
func run() int {
98110
lastTag := lastTag()
99111
latestTag := latestTag()
100-
cmd := exec.Command("git", "rev-list", lastTag+"..HEAD", "--merges", "--pretty=format:%B")
112+
cmd := exec.Command("git", "rev-list", lastTag+"..HEAD", "--merges", "--pretty=format:%B") // #nosec G204:gosec
101113

102114
merges := map[string][]string{
103115
features: {},
@@ -174,12 +186,15 @@ func run() int {
174186
merges[key] = append(merges[key], formatMerge(body, prNumber))
175187
}
176188

177-
// Add empty superseded section
178-
merges[superseded] = append(merges[superseded], "- `<insert superseded bumps and reverts here>`")
189+
// Add empty superseded section, if not beta/rc, we don't cleanup those notes
190+
if !isBeta(latestTag) && !isRC(latestTag) {
191+
merges[superseded] = append(merges[superseded], "- `<insert superseded bumps and reverts here>`")
192+
}
179193

180194
// TODO Turn this into a link (requires knowing the project name + organization)
181195
fmt.Printf("Changes since %v\n---\n", lastTag)
182196

197+
// print the changes by category
183198
for _, key := range outputOrder {
184199
mergeslice := merges[key]
185200
if len(mergeslice) > 0 {
@@ -189,10 +204,29 @@ func run() int {
189204
}
190205
fmt.Println()
191206
}
207+
208+
// if we're doing beta/rc, print breaking changes and hide the rest of the changes
209+
if key == warning {
210+
if isBeta(latestTag) {
211+
fmt.Printf(warningTemplate, "BETA RELEASE")
212+
}
213+
if isRC(latestTag) {
214+
fmt.Printf(warningTemplate, "RELEASE CANDIDATE")
215+
}
216+
if isBeta(latestTag) || isRC(latestTag) {
217+
fmt.Printf("<details>\n")
218+
fmt.Printf("<summary>More details about the release</summary>\n\n")
219+
}
220+
}
221+
}
222+
223+
// then close the details if we had it open
224+
if isBeta(latestTag) || isRC(latestTag) {
225+
fmt.Printf("</details>\n\n")
192226
}
193227

194-
fmt.Printf("The container image for this release is: %v\n", latestTag)
195-
fmt.Println("\nThanks to all our contributors! 😊")
228+
fmt.Printf("The image for this release is: %v\n", latestTag)
229+
fmt.Println("\n_Thanks to all our contributors!_ 😊")
196230

197231
return 0
198232
}

0 commit comments

Comments
 (0)