Documentation
¶
Overview ¶
Package semverutil provides shared semantic versioning primitives used across the pkg/workflow and pkg/cli packages. Centralizing these helpers ensures that semver parsing, comparison, and compatibility logic is fixed in one place.
Both workflow and cli packages previously duplicated the "ensure v-prefix" pattern and independently called golang.org/x/mod/semver. This package provides the canonical implementations so both packages can delegate here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare compares two semantic versions and returns 1 if v1 > v2, -1 if v1 < v2, or 0 if they are equal. A bare version without a leading "v" is accepted.
func EnsureVPrefix ¶
EnsureVPrefix returns v with a leading "v" added if it is not already present. The golang.org/x/mod/semver package requires the "v" prefix; callers that may receive bare version strings (e.g. "1.2.3") should normalise via this helper.
func IsActionVersionTag ¶
IsActionVersionTag reports whether s is a valid GitHub Actions version tag. Accepted formats are vmajor, vmajor.minor, and vmajor.minor.patch; prerelease and build-metadata suffixes are not accepted.
func IsCompatible ¶
IsCompatible reports whether pinVersion is semver-compatible with requestedVersion. Semver compatibility is defined as both versions sharing the same major version.
Examples:
- IsCompatible("v5.0.0", "v5") → true
- IsCompatible("v5.1.0", "v5.0.0") → true
- IsCompatible("v6.0.0", "v5") → false
Types ¶
type SemanticVersion ¶
SemanticVersion represents a parsed semantic version.
func ParseVersion ¶
func ParseVersion(v string) *SemanticVersion
ParseVersion parses v into a SemanticVersion. It returns nil if v is not a valid semantic version string.
func (*SemanticVersion) IsNewer ¶
func (v *SemanticVersion) IsNewer(other *SemanticVersion) bool
IsNewer returns true if this version is newer than other. Uses Compare for proper semantic version comparison.
func (*SemanticVersion) IsPreciseVersion ¶ added in v0.65.1
func (v *SemanticVersion) IsPreciseVersion() bool
IsPreciseVersion returns true if the version has explicit minor and patch components (i.e., at least two dots in the version string, e.g. "v6.0.0" is precise, "v6" is not).