2024-08-31 15:23:21 +02:00
|
|
|
package updater
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"regexp"
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var GenericUpdaterSemVerRegex = regexp.MustCompile(`\d+\.\d+\.\d+(-[\w.]+)?(.*x-releaser-pleaser-version)`)
|
|
|
|
|
|
2025-08-23 22:14:34 +02:00
|
|
|
func Generic(files []string) Updater {
|
|
|
|
|
return generic{
|
|
|
|
|
files: files,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type generic struct {
|
|
|
|
|
files []string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g generic) Files() []string {
|
|
|
|
|
return g.files
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g generic) CreateNewFiles() bool {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g generic) Update(info ReleaseInfo) func(content string) (string, error) {
|
|
|
|
|
return func(content string) (string, error) {
|
2024-08-31 15:23:21 +02:00
|
|
|
// We strip the "v" prefix to avoid adding/removing it from the users input.
|
|
|
|
|
version := strings.TrimPrefix(info.Version, "v")
|
|
|
|
|
|
|
|
|
|
return GenericUpdaterSemVerRegex.ReplaceAllString(content, version+"${2}"), nil
|
|
|
|
|
}
|
|
|
|
|
}
|