version

package
v0.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package version provides versioning strategies for calculating release versions.

Index

Constants

View Source
const DefaultCalVerFormat = "YYYY.0M.MICRO"

Variables

View Source
var ErrInvalidVersion = errors.New("invalid version")

Functions

func ValidateCalVerFormat added in v0.6.1

func ValidateCalVerFormat(format string) error

Types

type CalVer

type CalVer struct {
	Format string
	Prefix string
	Now    func() time.Time
}

CalVer implements calendar versioning. Supported formats use CalVer date tokens and a MICRO incrementing counter.

func (*CalVer) Current

func (c *CalVer) Current(tag string) (string, error)

func (*CalVer) InitialVersion

func (c *CalVer) InitialVersion() string

InitialVersion returns an empty string since calver starts from the current date.

func (*CalVer) Less added in v0.6.1

func (c *CalVer) Less(leftVersion, rightVersion, leftRef, rightRef string) bool

func (*CalVer) Next

func (c *CalVer) Next(current string, bump commit.BumpType) (string, error)

Next increments the micro counter if the current calendar period matches. Otherwise, it resets the micro counter to 1.

func (*CalVer) Tag

func (c *CalVer) Tag(version string) string

type SemVer

type SemVer struct {
	Prefix                     string
	PreMajorBreakingBumpsMinor bool
	PreMajorFeaturesBumpPatch  bool
}

func (*SemVer) Current

func (s *SemVer) Current(tag string) (string, error)

func (*SemVer) InitialVersion

func (s *SemVer) InitialVersion() string

func (*SemVer) Next

func (s *SemVer) Next(current string, bump commit.BumpType) (string, error)

func (*SemVer) Tag

func (s *SemVer) Tag(version string) string

type Strategy

type Strategy interface {
	// Current parses a version tag string into a normalized version.
	Current(tag string) (string, error)
	// Next calculates the next version based on the current version and bump type.
	Next(current string, bump commit.BumpType) (string, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL