version

package
v0.4.8 Latest Latest
Warning

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

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

Documentation

Overview

Package version provides versioning strategies for calculating release versions.

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type CalVer

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

CalVer implements calendar versioning. Supported format: YYYY.0M.MICRO where MICRO is an 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) Next

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

Next increments the micro counter if the current year/month 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