Build selected targets with version injection

This commit is contained in:
2026-10-05 19:20:58 +00:00
parent c83313b3b9
commit 5d6a6d10bd
12 changed files with 927 additions and 34 deletions

View File

@@ -0,0 +1,25 @@
package versioncontract
import "strings"
// ValidStableVersion reports whether version uses the selected vMAJOR.MINOR.PATCH form.
func ValidStableVersion(version string) bool {
if !strings.HasPrefix(version, "v") {
return false
}
components := strings.Split(version[1:], ".")
if len(components) != 3 {
return false
}
for _, component := range components {
if component == "" || len(component) > 1 && component[0] == '0' {
return false
}
for i := 0; i < len(component); i++ {
if component[i] < '0' || component[i] > '9' {
return false
}
}
}
return true
}