version

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package version implements finding the latest and greatest tagged version in a remote git repository.

Usage

In its simplest form, the following snippet finds the latest version for tags in semver format (MAJOR.MINOR.PATH, with MINOR and PATH being optional) with or without a "v" prefix. The latest semver found is returned, as well as its corresponding tag reference for further use.

remoteURL := "..." // ...could even be just a local path.
semver, ref, err := LatestReleaseTag(
    context.Background(),
    remoteURL,
    SemverTagMatcher(""))

In case the version tags feature a prefix, such as in "libfoo-1.6.66", use NewPrefixedTagMatcher:

semver, ref, err := LatestReleaseTag(
	context.Background(),
	remoteURL,
	NewPrefixedTagMatcher("libfoo-"))

Index

Constants

This section is empty.

Variables

View Source
var SemverTagMatcher = NewPrefixedTagMatcher("")

SemverTagMatcher is a version tag matcher that matches only on tags in semver version. That is, with an optional "v" prefix in the "MAJOR.MINOR.PATCH" format, where MINOR and PATCH are optional.

Functions

func LatestReleaseTag

func LatestReleaseTag(ctx context.Context, remoteURL string, fn VersionMatcherFn) (semanticver string, ref string, err error)

LatestReleaseTag determines the latest release tag in the specified remote git repository that matches the specified pattern, especially when combined with NewPrefixedTagMatcher.

Types

type VersionMatcherFn

type VersionMatcherFn func(refname string) (semver string)

VersionMatcherFn returns the semver information embedded in a refname. If the refname should not be taken into account, then any implementation of VersionMatcherFn should return an empty string instead.

func NewPrefixedTagMatcher

func NewPrefixedTagMatcher(prefix string) VersionMatcherFn

NewPrefixedTagMatcher returns a VersionMatcherFn to be used with LatestReleaseTag. The returned function only matches tags (/ref/tags/...) in the format <prefix><semver>. In particular, semvers must be in the format MAJOR, MAJOR.MINOR and MAJOR.MINOR.PATH with an optional "v" prefix, but no BUILD and PRERELEASE elements.

Jump to

Keyboard shortcuts

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