Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 support beta and rc releases in release note generator #1567

Merged
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
14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ endif

.PHONY: e2e-tests
e2e-tests: CONTAINER_RUNTIME?=docker # Env variable can override this default
export CONTAINER_RUNTIME
export CONTAINER_RUNTIME

e2e-tests: $(GINKGO) e2e-substitutions cluster-templates # This target should be called from scripts/ci-e2e.sh
for image in $(E2E_CONTAINERS); do \
Expand Down Expand Up @@ -226,7 +226,7 @@ build-api: ## Builds api directory.
.PHONY: build-e2e
build-e2e: ## Builds test directory.
cd $(TEST_DIR) && $(GO) build ./...

## --------------------------------------
## Tooling Binaries
## --------------------------------------
Expand Down Expand Up @@ -270,7 +270,7 @@ $(ENVSUBST):
$(KUSTOMIZE_BIN): $(KUSTOMIZE) ## Build a local copy of kustomize.

.PHONY: $(KUSTOMIZE)
$(KUSTOMIZE): $(TOOLS_DIR)/go.mod
$(KUSTOMIZE): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -tags=tools -o $(BIN_DIR)/$(KUSTOMIZE_BIN) sigs.k8s.io/kustomize/kustomize/v5

.PHONY: $(ENVSUBST_BIN)
Expand Down Expand Up @@ -494,7 +494,7 @@ ifneq (,$(findstring -,$(RELEASE_TAG)))
PRE_RELEASE=true
endif
# the previous release tag, e.g., v1.4.0, excluding pre-release tags
PREVIOUS_TAG ?= $(shell git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | sort -V | grep -B1 $(RELEASE_TAG) | head -n 1 2>/dev/null)
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)
RELEASE_DIR := out
RELEASE_NOTES_DIR := releasenotes

Expand All @@ -513,11 +513,7 @@ release-manifests: $(KUSTOMIZE) $(RELEASE_DIR) ## Builds the manifests to publis

.PHONY: release-notes
release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES)
if [ -n "${PRE_RELEASE}" ]; then \
echo ":rotating_light: This is a RELEASE CANDIDATE. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/metal3-io/cluster-api-provider-metal3/issues/new/)." > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
else \
$(GO) run ./hack/tools/release/notes.go --from=$(PREVIOUS_TAG) > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
fi
$(GO) run ./hack/tools/release/notes.go --from=$(PREVIOUS_TAG) > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md

.PHONY: release
release:
Expand Down
41 changes: 37 additions & 4 deletions hack/tools/release/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const (
superseded = ":recycle: Superseded or Reverted"
)

const (
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/cluster-api-provider-metal3/issues/new/).\n\n"
)

var (
outputOrder = []string{
warning,
Expand Down Expand Up @@ -85,6 +89,14 @@ func lastTag() string {
return string(bytes.TrimSpace(out))
}

func isBeta(tag string) bool {
return strings.Contains(tag, "-beta.")
}

func isRC(tag string) bool {
return strings.Contains(tag, "-rc.")
}

func firstCommit() string {
cmd := exec.Command("git", "rev-list", "--max-parents=0", "HEAD")
out, err := cmd.Output()
Expand All @@ -97,7 +109,7 @@ func firstCommit() string {
func run() int {
lastTag := lastTag()
latestTag := latestTag()
cmd := exec.Command("git", "rev-list", lastTag+"..HEAD", "--merges", "--pretty=format:%B")
cmd := exec.Command("git", "rev-list", lastTag+"..HEAD", "--merges", "--pretty=format:%B") // #nosec G204:gosec

merges := map[string][]string{
features: {},
Expand Down Expand Up @@ -174,12 +186,15 @@ func run() int {
merges[key] = append(merges[key], formatMerge(body, prNumber))
}

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

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

// print the changes by category
for _, key := range outputOrder {
mergeslice := merges[key]
if len(mergeslice) > 0 {
Expand All @@ -189,10 +204,28 @@ func run() int {
}
fmt.Println()
}

// if we're doing beta/rc, print breaking changes and hide the rest of the changes
if key == warning {
if isBeta(latestTag) {
fmt.Printf(warningTemplate, "BETA RELEASE")
}
if isRC(latestTag) {
fmt.Printf(warningTemplate, "RELEASE CANDIDATE")
}
if isBeta(latestTag) || isRC(latestTag) {
fmt.Printf("<details>\n")
fmt.Printf("<summary>More details about the release</summary>\n\n")
}
}
}

// then close the details if we had it open
if isBeta(latestTag) || isRC(latestTag) {
fmt.Printf("</details>\n\n")
}

fmt.Printf("The image for this release is: %v\n", latestTag)
fmt.Printf("Ironic image tag is capm3-%v\n", latestTag)
fmt.Printf("Mariadb image tag is capm3-%v\n", latestTag)
fmt.Println("\n_Thanks to all our contributors!_ 😊")

Expand Down
Loading