version

package
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package version provides CLI version information and version checking utilities.

Index

Constants

View Source
const (
	// GitHubAPIURL is the GitHub Releases API endpoint
	GitHubAPIURL = "https://api.github.com/repos/specledger/specledger/releases/latest"

	// CheckTimeout is the timeout for version check requests
	CheckTimeout = 5 * time.Second
)

Variables

View Source
var (
	// Version is the semantic version of the CLI
	Version = "dev"
	// Commit is the git commit hash
	Commit = "unknown"
	// Date is the build date
	Date = "unknown"
	// BuildType is the build type (development, production)
	BuildType = "development"
)

Build-time variables set by GoReleaser via ldflags

Functions

func FormatUpdateMessage

func FormatUpdateMessage(currentVersion, latestVersion string) string

FormatUpdateMessage formats a complete update message with all instructions.

func GetBuildDate

func GetBuildDate() string

GetBuildDate returns the build date.

func GetBuildType

func GetBuildType() string

GetBuildType returns the build type.

func GetCommit

func GetCommit() string

GetCommit returns the git commit hash.

func GetUpdateInstructions

func GetUpdateInstructions() string

GetUpdateInstructions returns installation-method-specific update instructions.

func GetUpdateInstructionsForMethod

func GetUpdateInstructionsForMethod(method InstallationMethod) string

GetUpdateInstructionsForMethod returns update instructions for a specific installation method.

func GetVersion

func GetVersion() string

GetVersion returns the current CLI version.

func IsDevBuild

func IsDevBuild() bool

IsDevBuild returns true if this is a development build.

func SelfUpdate

func SelfUpdate(ctx context.Context) error

SelfUpdate downloads and installs the latest version from GitHub Releases.

Types

type GitHubRelease

type GitHubRelease struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	HTMLURL     string    `json:"html_url"`
	PublishedAt time.Time `json:"published_at"`
}

GitHubRelease represents the GitHub Releases API response

type InstallationMethod

type InstallationMethod string

InstallationMethod represents how the CLI was installed

const (
	MethodHomebrew  InstallationMethod = "homebrew"
	MethodGoInstall InstallationMethod = "go-install"
	MethodBinary    InstallationMethod = "binary"
)

func DetectInstallationMethod

func DetectInstallationMethod() InstallationMethod

DetectInstallationMethod attempts to determine how the CLI was installed.

type VersionInfo

type VersionInfo struct {
	CurrentVersion  string    `json:"current_version"`  // Installed CLI version (e.g., "1.2.0")
	LatestVersion   string    `json:"latest_version"`   // Latest available version (e.g., "1.3.0")
	LatestURL       string    `json:"latest_url"`       // URL to release page
	UpdateAvailable bool      `json:"update_available"` // true if LatestVersion > CurrentVersion
	CheckedAt       time.Time `json:"checked_at"`       // When the check was performed
	Error           string    `json:"error,omitempty"`  // Error message if check failed
}

VersionInfo represents version information from GitHub Releases API.

func CheckLatestVersion

func CheckLatestVersion(ctx context.Context) *VersionInfo

CheckLatestVersion queries GitHub Releases API for the latest version. Returns VersionInfo with the latest version details, or an error message if check fails.

Jump to

Keyboard shortcuts

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