semver

package
v2.0.0-...-4b7107c Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 8 Imported by: 0

README

Semantic Version Tools

Description

A git-aware semantic versioning tool built in golang, which includes a re-usable GitHub Action. This thing is intended to automate more so that I can tag less and drink more coffee.

Usage

Each semantic version (SemanticVersion) object consists of a major, minor and patch version, where each part of the larger object is an unsigned 8-bit integer (0-255) and where the SemanticVersion bump methods will carry-over the overflow of patch to minor and minor to major. However, if major goes above 255, an error will be thrown.

The version number parts are tracked using the VersionNumber datatype and this could be changed from a size 8 to size 16 or or size 32 relatively quickly with only two changes (i.e. the VersionNumber type to uint16 or uint32, etc.) and the constant versionNumberSize to the appropriate bit size. Tests and code should handle the change transparently.

Installation
In your go project?

go get "github.com/sam-caldwell/go/v2/projects/semver"

var version SemanticVersion
if err:=version.BumpMajor(); err!=nil{
    panic(err)
}
if err:=version.BumpMinor(); err!=nil{
    panic(err)
}
if err:=version.BumpPatch(); err!=nil{
    panic(err)
}
if err:=version.UpdateTag(); err!= nil {
    panic(err)
}
fmt.Println(version.String())

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SemanticVersion

type SemanticVersion struct {
	// contains filtered or unexported fields
}

SemanticVersion - A semantic version (v0.0.0) with methods

func (*SemanticVersion) BumpMajor

func (ver *SemanticVersion) BumpMajor() error

BumpMajor - bump version part

func (*SemanticVersion) BumpMinor

func (ver *SemanticVersion) BumpMinor() error

BumpMinor - bump version part (with rollover to major)

func (*SemanticVersion) BumpPatch

func (ver *SemanticVersion) BumpPatch() error

BumpPatch - bump version part (with rollover to minor)

func (*SemanticVersion) GetMostRecentTag

func (ver *SemanticVersion) GetMostRecentTag() (err error)

GetMostRecentTag - Query the local git repo for the most recent tag

func (*SemanticVersion) Major

func (ver *SemanticVersion) Major() VersionNumber

func (*SemanticVersion) Minor

func (ver *SemanticVersion) Minor() VersionNumber

func (*SemanticVersion) Parse

func (ver *SemanticVersion) Parse(v string) (err error)

Parse - Parse a string into the semantic version numeric form

func (*SemanticVersion) ParseP

func (ver *SemanticVersion) ParseP(v *string) (err error)

ParseP - Parse a string into the semantic version numeric form

func (*SemanticVersion) Patch

func (ver *SemanticVersion) Patch() VersionNumber

func (*SemanticVersion) String

func (ver *SemanticVersion) String() string

String - return a semantic version string.

func (*SemanticVersion) UpdateTag

func (ver *SemanticVersion) UpdateTag() error

UpdateTag - update the current local git repo (current directory) with new tag.

type VersionNumber

type VersionNumber uint8

VersionNumber - a 8-bit unsigned version number

func (*VersionNumber) Bump

func (ver *VersionNumber) Bump() error

func (*VersionNumber) Put

func (ver *VersionNumber) Put(s string) error

Put - Convert string to uint (VersionNumber) and store

func (*VersionNumber) PutP

func (ver *VersionNumber) PutP(s *string) error

PutP - Convert string to uint (VersionNumber) and store

Jump to

Keyboard shortcuts

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