Skip to content

Commit

Permalink
cmd/release: generate release notes depending on branches
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aanm committed Sep 4, 2024
1 parent b5e1369 commit 5294555
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/release/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5294555

Please sign in to comment.