refactor: interface for versioning strategy

This commit is contained in:
Julian Tölle 2024-08-08 18:30:15 +02:00
parent 7797a86a48
commit 04ace5cb05
3 changed files with 106 additions and 109 deletions

View file

@ -13,7 +13,11 @@ type Releases struct {
Stable *Tag
}
func (r Releases) NextVersion(versionBump conventionalcommits.VersionBump, nextVersionType NextVersionType) (string, error) {
type VersioningStrategy = func(Releases, conventionalcommits.VersionBump, NextVersionType) (string, error)
var _ VersioningStrategy = SemVerNextVersion
func SemVerNextVersion(r Releases, versionBump conventionalcommits.VersionBump, nextVersionType NextVersionType) (string, error) {
latest, err := parseSemverWithDefault(r.Latest)
if err != nil {
return "", fmt.Errorf("failed to parse latest version: %w", err)