From 5294555ec3daf9aee7a1536207bd06fda700b43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Martins?= Date: Wed, 4 Sep 2024 21:29:51 +0200 Subject: [PATCH] cmd/release: generate release notes depending on branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the previous version is from a different branch then we need to include it as "lastStable" so that it correctly generate the release notes. Signed-off-by: André Martins --- cmd/release/git.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/release/git.go b/cmd/release/git.go index 5ec7c1b..da0df3c 100644 --- a/cmd/release/git.go +++ b/cmd/release/git.go @@ -30,6 +30,7 @@ import ( "syscall" "github.com/cilium/release/cmd/changelog" + "github.com/cilium/release/pkg/github" io2 "github.com/cilium/release/pkg/io" progressbar "github.com/schollz/progressbar/v3" "golang.org/x/mod/semver" @@ -220,13 +221,22 @@ func (pc *PrepareCommit) generateChangeLog(ctx context.Context, ghClient *GHClie } commitSha := strings.TrimSpace(string(commitShaRaw)) + // If we are doing a pre-release from the main branch then the remote + // branch doesn't exist. + var lastStable string + if semver.MajorMinor(pc.cfg.TargetVer) != semver.MajorMinor(pc.cfg.PreviousVer) { + lastStable = github.MajorMinorErsion(pc.cfg.PreviousVer) + } + // Generate the CHANGELOG from previous release to current release. io2.Fprintf(3, os.Stdout, "✍️ Generating CHANGELOG.md from %s to %s\n", previousPatchVersion, commitSha) + io2.Fprintf(4, os.Stdout, "Previous and current version are from different branches, using last stable %q for release notes\n", lastStable) clCfg := changelog.ChangeLogConfig{ CommonConfig: pc.cfg.CommonConfig, Base: previousPatchVersion, Head: commitSha, StateFile: pc.cfg.StateFile, + LastStable: lastStable, } err = clCfg.Sanitize() if err != nil {