mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-02-08 10:47:02 +00:00
feat: add helmchart updater
Signed-off-by: skuethe <56306041+skuethe@users.noreply.github.com>
This commit is contained in:
parent
8d6175c13b
commit
9cb85f630c
5 changed files with 109 additions and 2 deletions
35
internal/updater/helmchart.go
Normal file
35
internal/updater/helmchart.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package updater
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// HelmChart creates an updater that modifies the version field in Chart.yaml files
|
||||
func HelmChart() Updater {
|
||||
return helmchart{}
|
||||
}
|
||||
|
||||
type helmchart struct{}
|
||||
|
||||
func (h helmchart) Files() []string {
|
||||
return []string{"Chart.yaml"}
|
||||
}
|
||||
|
||||
func (h helmchart) CreateNewFiles() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (h helmchart) Update(info ReleaseInfo) func(content string) (string, error) {
|
||||
return func(content string) (string, error) {
|
||||
// Regex to match ^version: ...$ with flexible whitespace in multiline mode
|
||||
versionRegex := regexp.MustCompile(`(?m:^(version:\s*)\S*$)`)
|
||||
|
||||
// Check if the file contains a version field
|
||||
if !versionRegex.MatchString(content) {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
// Replace the version value while preserving the original formatting
|
||||
return versionRegex.ReplaceAllString(content, `${1}`+info.Version), nil
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue