Skip to content
k1LoWPublic

About

calver is a package/tool provides the ability to work with Calendar Versioning in Go.

Topics

Resources

Stars

24 stars

Watchers

1 watching

Forks

Repository files navigation

calver CI Go Reference Coverage Code to Test Ratio

calver is a package/tool provides the ability to work with Calendar Versioning in Go.

Usage

As a package

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
}

As a tool

$ 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

Example: Generate version like Ubuntu

$ 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

Example: Use modifier

$ 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

Example: Get latest version and generate next version

$ 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.2

Week-based versions

When 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.

Install

As a package

$ go get github.com/k1LoW/calver

As a tool

deb:

$ 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.deb

RPM:

$ export CALVER_VERSION=X.X.X
$ yum install https://github.com/k1LoW/calver/releases/download/v$CALVER_VERSION/calver_$CALVER_VERSION-1_amd64.rpm

apk:

$ 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.apk

homebrew tap:

$ brew install k1LoW/tap/calver

manually:

Download binary from releases page

go install:

$ go install github.com/k1LoW/calver/cmd/calver@latest

About

calver is a package/tool provides the ability to work with Calendar Versioning in Go.

Topics

Resources

Stars

24 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages