Skip to content

Commit

Permalink
Mage: Stop mutating release notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gacko committed Jul 8, 2024
1 parent a8f0f3b commit 0dcb1d8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions magefiles/steps/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ package steps

import (
"bytes"
"fmt"
"os"
"strings"

semver "github.com/blang/semver/v4"
"github.com/helm/helm/pkg/chartutil"
Expand Down Expand Up @@ -104,18 +102,21 @@ func updateVersion(version string) {
utils.CheckIfError(err, "HELM Saving new Chart")
}

func updateChartReleaseNotes(releasesNotes []string) {
utils.Info("HELM Updating the Chart Release notes")
func updateChartReleaseNotes(releaseNotes []string) {
utils.Info("HELM Updating chart release notes")
chart, err := chartutil.LoadChartfile(HelmChartPath)
utils.CheckIfError(err, "HELM Could not Load Chart to update release notes %s", HelmChartPath)
for i := range releasesNotes {
releasesNotes[i] = fmt.Sprintf("- %q", releasesNotes[i])
}
releaseNoteString := strings.Join(releasesNotes, "\n")
utils.Info("HELM Release note string %s", releaseNoteString)
chart.Annotations["artifacthub.io/changes"] = releaseNoteString
utils.CheckIfError(err, "HELM Failed to load chart manifest: %s", HelmChartPath)

releaseNotesBytes, err := yaml.Marshal(releaseNotes)
utils.CheckIfError(err, "HELM Failed to marshal release notes")

releaseNotesString := string(releaseNotesBytes)
utils.Info("HELM Chart release notes:\n%s", releaseNotesString)
chart.Annotations["artifacthub.io/changes"] = releaseNotesString

utils.Info("HELM Saving chart release notes")
err = chartutil.SaveChartfile(HelmChartPath, chart)
utils.CheckIfError(err, "HELM Saving updated release notes for Chart")
utils.CheckIfError(err, "HELM Failed to save chart manifest: %s", HelmChartPath)
}

// UpdateChartValue Updates the Helm ChartValue
Expand Down

0 comments on commit 0dcb1d8

Please sign in to comment.