Build selected targets with version injection
This commit is contained in:
25
internal/versioncontract/version.go
Normal file
25
internal/versioncontract/version.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user