Skip to content

Commit

Permalink
compare with correct tag
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth Bingham <[email protected]>
  • Loading branch information
qrkourier committed Aug 8, 2024
1 parent 0732e68 commit ffc7629
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/Songmu/retry"
"github.com/pkg/errors"
"helm.sh/helm/v3/pkg/chart"

"github.com/blang/semver"
"github.com/google/go-github/v56/github"
Expand Down Expand Up @@ -151,9 +152,9 @@ func (c *Client) GetLatestChartRelease(_ context.Context, prefix string) (*Relea
}

// GenerateReleaseNotes generates the release notes for a release
func (c *Client) GenerateReleaseNotes(_ context.Context, latestRelease *Release, nextRelease string) (string, error) {
func (c *Client) GenerateReleaseNotes(_ context.Context, latestRelease *Release, chart *chart.Chart) (string, error) {
notes, _, err := c.Repositories.GenerateReleaseNotes(context.TODO(), c.owner, c.repo, &github.GenerateNotesOptions{
TagName: nextRelease,
TagName: chart.Metadata.Name + "-" + chart.Metadata.Version,
PreviousTagName: &latestRelease.Name,
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/releaser/releaser.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type GitHub interface {
GetRelease(ctx context.Context, tag string) (*github.Release, error)
CreatePullRequest(owner string, repo string, message string, head string, base string) (string, error)
GetLatestChartRelease(ctx context.Context, prefix string) (*github.Release, error)
GenerateReleaseNotes(ctx context.Context, latestRelease *github.Release, nextRelease string) (string, error)
GenerateReleaseNotes(ctx context.Context, latestRelease *github.Release, chart *chart.Chart) (string, error)
}

type Git interface {
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *Releaser) getReleaseNotes(chart *chart.Chart) (string, error) {
highest := versions[len(versions)-1]
// skip generating notes if there's already a higher version in GitHub
if nextVersion.String() == highest.String() {
notes, err := r.github.GenerateReleaseNotes(context.TODO(), latestRelease, chart.Metadata.Version)
notes, err := r.github.GenerateReleaseNotes(context.TODO(), latestRelease, chart)
if err != nil {
return "", errors.Wrapf(err, "failed to generate release notes for chart %s", chart.Metadata.Name)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/releaser/releaser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"helm.sh/helm/v3/pkg/repo"

"github.com/helm/chart-releaser/pkg/config"
"helm.sh/helm/v3/pkg/chart"
)

type FakeGitHub struct {
Expand Down Expand Up @@ -133,8 +134,8 @@ func (f *FakeGitHub) GetLatestChartRelease(_ context.Context, prefix string) (*g
}

// GenerateReleaseNotes generates the release notes for a release
func (f *FakeGitHub) GenerateReleaseNotes(_ context.Context, latestRelease *github.Release, nextRelease string) (string, error) {
f.Called(latestRelease, nextRelease)
func (f *FakeGitHub) GenerateReleaseNotes(_ context.Context, latestRelease *github.Release, chart *chart.Chart) (string, error) {
f.Called(latestRelease, chart)

notes := "# Noted."

Expand Down

0 comments on commit ffc7629

Please sign in to comment.