Documentation
¶
Overview ¶
Package upgrade implements self-update for the ezs and ezs-mcp binaries.
It downloads the matching release tarball from GitHub, verifies the SHA-256 against checksums.txt, and atomically swaps the running binary (and its sibling) on disk. `go install` users are upgraded by re-running `go install` against the latest release tag so the toolchain remains the source of truth for their install. Homebrew users are routed back to `brew upgrade ezstack` so brew's receipt of the install stays in sync with the binary on disk.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatchingAsset = errors.New("no release asset matches this platform")
ErrNoMatchingAsset is returned when no release asset matches the runtime os/arch. Surfaced as its own type so the CLI layer can print a platform-specific hint.
Functions ¶
func AssetName ¶
AssetName returns the goreleaser archive name for the current runtime. It only knows about platforms we actually publish (linux/darwin x amd64/arm64).
func CompareVersions ¶
CompareVersions compares two semver-ish strings (with optional leading v). Returns -1 if a<b, 0 if equal, +1 if a>b. Pre-release suffixes follow semver: a version with a pre-release is less than the same version without one (so 4.6.3-rc.1 < 4.6.3), and pre-release identifiers are compared lexicographically as a fallback. Invalid input never panics, it just sorts deterministically.
Types ¶
type Asset ¶
type Asset struct {
Name string `json:"name"`
DownloadURL string `json:"browser_download_url"`
Size int64 `json:"size"`
}
Asset is one downloadable artifact attached to a release.
type InstallMethod ¶
type InstallMethod int
InstallMethod is how the running ezs binary was installed. Only Binary is upgraded in place; the others print a routing message instead so the upgrade stays consistent with how the user originally installed.
const ( InstallBinary InstallMethod = iota InstallHomebrew InstallGoInstall )
func DetectInstall ¶
func DetectInstall(execPath string) InstallMethod
DetectInstall classifies how the binary at execPath was installed. Symlinks must be resolved by the caller before passing the path here.
func (InstallMethod) String ¶
func (m InstallMethod) String() string
type ManagedInstallError ¶
type ManagedInstallError struct {
Method InstallMethod
ExecPath string
}
ManagedInstallError signals that the binary is owned by a package manager and the user must upgrade through that channel. The CLI catches this and prints a tailored hint. Only Homebrew installs end up here today — `go install` installs are upgraded in-process by re-running `go install`.
func (*ManagedInstallError) Error ¶
func (e *ManagedInstallError) Error() string
type NetworkError ¶
type NetworkError struct {
// Op is a short label describing the failing operation, e.g.
// "github api" or "download <url>".
Op string
Err error
}
NetworkError wraps any HTTP-level failure (GitHub API call or asset download) so the CLI layer can route it to a network-specific exit code. Use errors.As to extract.
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type Options ¶
type Options struct {
// CurrentVersion is what the running binary reports (no leading "v").
CurrentVersion string
// TargetTag pins to a specific release tag like "v4.6.0". Empty
// means "latest published release".
TargetTag string
// Force replaces the binary even when CurrentVersion already matches.
Force bool
// CheckOnly prints the comparison and exits without downloading.
CheckOnly bool
// IncludeMCP also swaps a sibling ezs-mcp binary if one exists in
// the same directory.
IncludeMCP bool
// Confirm is called between the version check and the download.
// Returning false aborts cleanly. nil auto-confirms.
Confirm func(prompt string) bool
// Logf receives progress messages, one per call, no trailing newline.
// nil discards.
Logf func(format string, args ...any)
}
Options controls a single upgrade run.
type Release ¶
Release is the trimmed GitHub release payload we care about.
func LatestRelease ¶
LatestRelease fetches the latest published (non-prerelease) release.
type Result ¶
type Result struct {
From string
To string
Method InstallMethod
Updated []string // absolute paths of binaries that were replaced
AlreadyAtTip bool // true when no upgrade was performed
Cancelled bool // user said no at the confirm prompt
}
Result describes what an upgrade run actually did.