calver is a package/tool provides the ability to work with Calendar Versioning in Go.
package main
import (
"fmt"
"github.com/k1LoW/calver"
)
func main() {
cv, _ := calver.Parse("YY.0M.MICRO", "23.05.1")
fmt.Println(cv) // Output: 23.05.1
ncv, _ := cv.Next()
fmt.Println(ncv) // Output: 23.05.2
}$ date
Tue May 9 13:04:09 UTC 2023
$ calver --layout YY.0M.MICRO
23.5.0
$ calver --layout YY.0M.MICRO | calver --layout YY.0M.MICRO --next
23.5.1$ date
Tue May 9 13:04:09 UTC 2023
$ calver --layout YY.0M.MICRO --trim-suffix
2023.05
$ calver --layout YY.0M.MICRO --trim-suffix | calver --layout YY.0M.MICRO --trim-suffix --next
2023.05.1$ date
Tue May 9 13:04:09 UTC 2023
$ calver --layout YY.0M.MICRO-MODIFIER --trim-suffix --modifier dev
2023.05-dev
$ calver 23.05-dev --layout YY.0M.MICRO-MODIFIER --trim-suffix --next
2023.05
$ calver 23.05 --layout YY.0M.MICRO-MODIFIER --trim-suffix --next
2023.05.1$ date
Tue May 9 13:04:09 UTC 2023
$ gh release list | cut -f 1
v1.1.2
v1.1.1
2023.05.1
2023.05.0
v1.1.0
v1.0.1
2023.03.1
2023.03.0
v1.0.0
2023.02.0
v0.1.0
$ gh release list | cut -f 1 | calver --layout YY.0M.MICRO
2023.05.1
$ gh release list | cut -f 1 | calver --layout YY.0M.MICRO --next
2023.05.2When a layout includes WW or 0W, its year token (YYYY, YY, or 0Y) uses
the ISO week-numbering year, not the calendar year. For example, YYYY.0W.MICRO
generates 2026.01.0 on December 29, 2025 and 2026.53.0 on January 1, 2027.
Parsing preserves these versions, and subsequent releases in the same ISO week
increment MICRO.
Week tokens cannot be combined with month (MM, 0M) or day (DD, 0D) tokens.
Invalid ISO weeks, including week 53 in a year with only 52 weeks, are rejected.
Layouts without week tokens continue to use calendar years.
Previously, week-based layouts generated calendar years alongside ISO week numbers. Existing tags created near New Year may therefore need review before upgrading: a valid year/week pair is now interpreted as an ISO week date, and an invalid pair is rejected rather than normalized.
$ go get github.com/k1LoW/calverdeb:
$ export CALVER_VERSION=X.X.X
$ curl -o calver.deb -L https://github.com/k1LoW/calver/releases/download/v$CALVER_VERSION/calver_$CALVER_VERSION-1_amd64.deb
$ dpkg -i calver.debRPM:
$ export CALVER_VERSION=X.X.X
$ yum install https://github.com/k1LoW/calver/releases/download/v$CALVER_VERSION/calver_$CALVER_VERSION-1_amd64.rpmapk:
$ export CALVER_VERSION=X.X.X
$ curl -o calver.apk -L https://github.com/k1LoW/calver/releases/download/v$CALVER_VERSION/calver_$CALVER_VERSION-1_amd64.apk
$ apk add calver.apkhomebrew tap:
$ brew install k1LoW/tap/calvermanually:
Download binary from releases page
go install:
$ go install github.com/k1LoW/calver/cmd/calver@latest