Merge pull request #9568 from strongjz/update-mage-release
add ah and helm chart linting to release
This commit is contained in:
commit
9bbe2d5aab
2 changed files with 42 additions and 4 deletions
|
@ -32,6 +32,7 @@ import (
|
||||||
|
|
||||||
const HelmChartPath = "charts/ingress-nginx/Chart.yaml"
|
const HelmChartPath = "charts/ingress-nginx/Chart.yaml"
|
||||||
const HelmChartValues = "charts/ingress-nginx/values.yaml"
|
const HelmChartValues = "charts/ingress-nginx/values.yaml"
|
||||||
|
const ArtHubImage = "public.ecr.aws/artifacthub/ah:v1.5.0"
|
||||||
|
|
||||||
type Helm mg.Namespace
|
type Helm mg.Namespace
|
||||||
|
|
||||||
|
@ -100,9 +101,13 @@ func updateChartReleaseNotes(releasesNotes []string) {
|
||||||
Info("HELM Updating the Chart Release notes")
|
Info("HELM Updating the Chart Release notes")
|
||||||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||||
CheckIfError(err, "HELM Could not Load Chart to update release notes %s", HelmChartPath)
|
CheckIfError(err, "HELM Could not Load Chart to update release notes %s", HelmChartPath)
|
||||||
var releaseNoteString string
|
releaseNoteString := ""
|
||||||
for i := range releasesNotes {
|
for i := range releasesNotes {
|
||||||
releaseNoteString = fmt.Sprintf("%s - %s\n", releaseNoteString, releasesNotes[i])
|
if len(releaseNoteString) == 0 {
|
||||||
|
releaseNoteString = fmt.Sprintf("- \"%s\"\n", releasesNotes[i])
|
||||||
|
} else {
|
||||||
|
releaseNoteString = fmt.Sprintf("%s- \"%s\"\n", releaseNoteString, releasesNotes[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Info("HELM Release note string %s", releaseNoteString)
|
Info("HELM Release note string %s", releaseNoteString)
|
||||||
chart.Annotations["artifacthub.io/changes"] = releaseNoteString
|
chart.Annotations["artifacthub.io/changes"] = releaseNoteString
|
||||||
|
@ -119,6 +124,36 @@ func (Helm) UpdateChartValue(key, value string) {
|
||||||
updateChartValue(key, value)
|
updateChartValue(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runArtifactHub() error {
|
||||||
|
Info("---------------------Running Artifact Hub Lint on Charts---------------")
|
||||||
|
dir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
ErrorF("Could not get current dir %s", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sh.RunV("docker",
|
||||||
|
"run",
|
||||||
|
"--rm",
|
||||||
|
"-v", fmt.Sprintf("%s:/work", dir),
|
||||||
|
"-w", "/work",
|
||||||
|
ArtHubImage,
|
||||||
|
"ah", "lint", "-p", "charts/ingress-nginx")
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateHelm() error {
|
||||||
|
err := runArtifactHub()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
Info("---------------------Running Verify Charts Lint Script---------------")
|
||||||
|
err = sh.RunV("./build/run-in-docker.sh", "./hack/verify-chart-lint.sh")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func updateChartValue(key, value string) {
|
func updateChartValue(key, value string) {
|
||||||
Info("HELM Updating Chart %s %s:%s", HelmChartValues, key, value)
|
Info("HELM Updating Chart %s %s:%s", HelmChartValues, key, value)
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,9 @@ func (Release) NewRelease(version string) {
|
||||||
|
|
||||||
releaseNotes.helmTemplate()
|
releaseNotes.helmTemplate()
|
||||||
|
|
||||||
|
err = validateHelm()
|
||||||
|
CheckIfError(err, "RELEASE Validating Helm Chart Changes")
|
||||||
|
|
||||||
//update static manifest
|
//update static manifest
|
||||||
CheckIfError(updateStaticManifest(), "Error Updating Static manifests")
|
CheckIfError(updateStaticManifest(), "Error Updating Static manifests")
|
||||||
|
|
||||||
|
@ -293,7 +296,7 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
||||||
var helmUpdates []string
|
var helmUpdates []string
|
||||||
prRegex := regexp.MustCompile("\\(#\\d+\\)")
|
prRegex := regexp.MustCompile("\\(#\\d+\\)")
|
||||||
depBot := regexp.MustCompile("^(\\w){1,10} Bump ")
|
depBot := regexp.MustCompile("^(\\w){1,10} Bump ")
|
||||||
helmRegex := regexp.MustCompile("helm|chart")
|
helmRegex := regexp.MustCompile("helm|chart|(?i)values")
|
||||||
for i, s := range commits {
|
for i, s := range commits {
|
||||||
//matches on PR
|
//matches on PR
|
||||||
if prRegex.Match([]byte(s)) {
|
if prRegex.Match([]byte(s)) {
|
||||||
|
@ -413,7 +416,7 @@ func (r ReleaseNote) helmTemplate() {
|
||||||
Debug("ChangeLog Templates %s", string(changelogTemplate))
|
Debug("ChangeLog Templates %s", string(changelogTemplate))
|
||||||
t := template.Must(template.New("changelog").Parse(string(changelogTemplate)))
|
t := template.Must(template.New("changelog").Parse(string(changelogTemplate)))
|
||||||
// create a new file
|
// create a new file
|
||||||
file, err := os.Create(fmt.Sprintf("charts/ingress-nginx/changelog/Changelog-%s.md", r.Version))
|
file, err := os.Create(fmt.Sprintf("charts/ingress-nginx/changelog/Changelog-%s.md", r.NewHelmChartVersion))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorF("Could not create changelog file %s", err)
|
ErrorF("Could not create changelog file %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue