selfupdate

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package selfupdate resolves which install channel delivered the running binary and builds the matching gechr/clive updater for it.

jira-cli ships six ways. Two self-update in place: Homebrew installs go through clive's brew backend (formula refresh + upgrade), and release-archive installs (the one-line installer, mise-free manual downloads) go through clive's github backend (checksum-verified, rollback-safe binary swap). The rest are owned by their installer and are pointed at the exact command instead: Scoop and mise manage versioned install trees an in-place swap would desynchronize, and clive's goinstall backend installs `<module>@latest`, which cannot target this module's cmd/jira main package.

Index

Constants

View Source
const (
	// ScoopHint updates a Scoop-managed install.
	ScoopHint = "scoop update jira"
	// MiseHint updates a mise-managed install.
	MiseHint = "mise up github:matcra587/jira-cli"
	// GoInstallHint rebuilds a go-install binary. The main package lives under
	// cmd/jira, which clive's goinstall backend (module-root installs only)
	// cannot target — hence a hint rather than a self-update.
	GoInstallHint = "go install " + Module + "/cmd/jira@latest"
)

Hints are the exact update commands for channels whose installer owns the binary; jira never self-replaces these.

View Source
const Module = "github.com/matcra587/jira-cli"

Module is the Go module path releases are published under; it locates the GitHub repository for release lookups and version links.

Variables

This section is empty.

Functions

func NotifyTool

func NotifyTool() updater.Tool

NotifyTool is the tool identity the passive update notifier (clive/notify) consumes. It is channel-independent: the latest ref comes from the GitHub releases API (no Go toolchain needed on any channel), and the binary name is pinned to "jira" so the kill switch derives to JIRA_NO_UPDATE_CHECK and the hint names `jira update` — which routes every channel correctly, either self-updating or printing that channel's installer command.

func UpdateAvailable

func UpdateAvailable(current, latest string) bool

UpdateAvailable reports whether latest is a strictly newer version than current, using clive's dev-build-aware semver rules. Unparseable input reports false: a from-source build never auto-updates on a bad compare.

Types

type Channel

type Channel string

Channel identifies how the running binary was installed.

const (
	// ChannelBrew is a Homebrew-managed binary (Cellar or a brew prefix path);
	// self-updated via `brew upgrade` through clive's brew backend.
	ChannelBrew Channel = "brew"
	// ChannelScoop is a binary running out of a Scoop apps or shims directory.
	ChannelScoop Channel = "scoop"
	// ChannelMise is a mise-managed release-archive install.
	ChannelMise Channel = "mise"
	// ChannelGoInstall is a module-proxy build (`go install ...@version`),
	// recognized by a real module version in the embedded build info.
	ChannelGoInstall Channel = "go-install"
	// ChannelArchive is a GoReleaser release-archive binary outside any
	// installer-managed tree, recognized by the BuildBy=goreleaser ldflag stamp.
	ChannelArchive Channel = "github-archive"
	// ChannelUnknown is anything else — typically a from-source `go build`.
	ChannelUnknown Channel = "unknown"
)

func Detect

func Detect() Channel

Detect resolves the running binary's install channel from its executable path and embedded build metadata. Symlinks are resolved first so a brew prefix symlink (e.g. /opt/homebrew/bin/jira -> ../Cellar/...) is seen as its Cellar target.

func (Channel) SelfUpdates

func (c Channel) SelfUpdates() bool

SelfUpdates reports whether jira replaces this channel's binary itself (rather than deferring to the channel's own installer or refusing).

type Updater

type Updater interface {
	// Latest returns the newest installable release ref, fetched over the
	// network without a Go toolchain.
	Latest(ctx context.Context) (string, error)
	// Update installs the latest release over the current install.
	Update(ctx context.Context) error
}

Updater checks for and installs the latest release through the backend that matches an install channel. Both implementations report progress and the old→new result line through clog on stderr.

func NewUpdater

func NewUpdater(ch Channel) (Updater, error)

NewUpdater builds the Updater for a self-updating channel: clive's brew backend for ChannelBrew, clive's github release-asset backend (replacing the running executable in place) for ChannelArchive. Any other channel is an error — callers gate on Channel.SelfUpdates first. It returns the Updater interface deliberately: the implementation is a runtime choice between two backends the caller must stay agnostic of.

Jump to

Keyboard shortcuts

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