From 2d67ec293526470a9f91bdc3794834670f5f44c7 Mon Sep 17 00:00:00 2001 From: Marco Ebert Date: Mon, 8 Jul 2024 11:04:34 +0200 Subject: [PATCH] Mage: Stop mutating release notes. --- magefiles/steps/helm.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/magefiles/steps/helm.go b/magefiles/steps/helm.go index b53283f78..245f5e1c0 100644 --- a/magefiles/steps/helm.go +++ b/magefiles/steps/helm.go @@ -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