in release/release.go [522:571]
func NextReleaseID(tags []string) (next string) {
const releaseTagPrefix = "release-"
const dt = "2006-01-02"
ct := nowTime().UTC()
nextTime := time.Date(ct.Year(), ct.Month(), ct.Day(), 0, 0, 0, 0, time.UTC)
latestNum := 0
for _, tag := range tags {
if !strings.HasPrefix(tag, releaseTagPrefix) {
continue
}
tag = strings.TrimPrefix(tag, releaseTagPrefix)
split := strings.SplitN(tag, ".", 2)
t, err := time.Parse(dt, split[0])
if err != nil {
continue
}
if !t.Equal(nextTime) {
continue
}
if len(split) != 2 {
if latestNum == 0 {
latestNum = 1
}
continue
}
i, err := strconv.Atoi(split[1])
if err != nil {
continue
}
if i > latestNum {
latestNum = i
}
}
if latestNum == 0 {
return nextTime.Format(dt)
}
latestNum++
return nextTime.Format(dt) + "." + strconv.Itoa(latestNum)
}