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 ( import (
"bytes" "bytes"
"fmt"
"os" "os"
"strings"
semver "github.com/blang/semver/v4" semver "github.com/blang/semver/v4"
"github.com/helm/helm/pkg/chartutil" "github.com/helm/helm/pkg/chartutil"
@ -104,18 +102,21 @@ func updateVersion(version string) {
utils.CheckIfError(err, "HELM Saving new Chart") utils.CheckIfError(err, "HELM Saving new Chart")
} }
func updateChartReleaseNotes(releasesNotes []string) { func updateChartReleaseNotes(releaseNotes []string) {
utils.Info("HELM Updating the Chart Release notes") utils.Info("HELM Updating chart release notes")
chart, err := chartutil.LoadChartfile(HelmChartPath) chart, err := chartutil.LoadChartfile(HelmChartPath)
utils.CheckIfError(err, "HELM Could not Load Chart to update release notes %s", HelmChartPath) utils.CheckIfError(err, "HELM Failed to load chart manifest: %s", HelmChartPath)
for i := range releasesNotes {
releasesNotes[i] = fmt.Sprintf("- %q", releasesNotes[i]) releaseNotesBytes, err := yaml.Marshal(releaseNotes)
} utils.CheckIfError(err, "HELM Failed to marshal release notes")
releaseNoteString := strings.Join(releasesNotes, "\n")
utils.Info("HELM Release note string %s", releaseNoteString) releaseNotesString := string(releaseNotesBytes)
chart.Annotations["artifacthub.io/changes"] = releaseNoteString 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) 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 // UpdateChartValue Updates the Helm ChartValue