Mage: Stop mutating release notes.

This commit is contained in:
Marco Ebert 2024-07-08 11:04:34 +02:00
parent dbe499437e
commit 2d67ec2935

View file

@ -18,9 +18,7 @@ package steps
import (
"bytes"
"fmt"
"os"
"strings"
semver "github.com/blang/semver/v4"
"github.com/helm/helm/pkg/chartutil"
@ -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