Documentation
¶
Index ¶
- Constants
- func Apply(rel *Release, targetPath, currentVersion string) error
- func ApplyStaged(current, targetPath string) (string, error)
- func AssetName() string
- func CachedNotice(current string) string
- func CheckAndApply(currentVersion string) (string, error)
- func ClearStaging()
- func IsHomebrewPath(path string) bool
- func IsNewer(latest, current string) bool
- func IsReleaseVersion(version string) bool
- func RecordCheck(rel *Release)
- func Restart(exePath string) error
- func Rollback(currentVersion, targetPath string) (string, error)
- func RunWorker(current string)
- func SetSkipVersion(version string)
- func ShouldSpawnWorker(current, mode string) bool
- func SkipVersion() string
- func SpawnWorker()
- func Stage(rel *Release) error
- func StagedVersion() string
- type Asset
- type Release
Constants ¶
const ( ModeOn = "on" // stage and apply updates automatically ModeNotify = "notify" // only print a notice when a release is available ModeOff = "off" // no checks at all )
Auto-update modes; config.Settings.AutoUpdateMode resolves to one of these.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply downloads, verifies, and installs rel's binary at targetPath, keeping the replaced binary (running as currentVersion) as the rollback backup. On failure the old binary is left in place.
func ApplyStaged ¶
ApplyStaged swaps a valid staged binary into targetPath and returns the new version, or "" when nothing applied. The manifest is re-verified against the staged file so a corrupt or foreign binary is never installed; any invalid staging area is discarded.
func AssetName ¶
func AssetName() string
AssetName returns the release archive filename for the current platform, matching the name_template in .goreleaser.yaml.
func CachedNotice ¶
CachedNotice returns the newer release recorded by a previous background check, or "". Reads only local state, never the network.
func CheckAndApply ¶
CheckAndApply is the host daemon's update pass: check for a release, download, verify, and swap the running binary in place. Returns the installed version, or "" when already current. The caller restarts into the new binary.
func IsHomebrewPath ¶
IsHomebrewPath reports whether a resolved executable path is managed by Homebrew and must be updated via brew instead. Cellar covers formulae and Caskroom covers casks; on Apple Silicon both sit under /opt/homebrew, but on an Intel Mac the prefix is /usr/local, so the Caskroom check is what catches a cask install there.
func IsNewer ¶
IsNewer reports whether latest is a higher version worth updating to.
Anything that is not a plain release is refused, even though semver orders v1.6.0-rc1 above v1.5.1: installing one stamps the binary with a version IsReleaseVersion rejects, so that install would stop checking for updates altogether. release.prerelease in .goreleaser.yaml already keeps an -rc out of releases/latest; this is the second lock on the same door.
func IsReleaseVersion ¶
IsReleaseVersion reports whether version comes from an exact release tag, as opposed to "dev" or a between-tags/dirty git describe string.
func RecordCheck ¶
func RecordCheck(rel *Release)
RecordCheck persists the result of a release lookup so later runs can skip re-querying GitHub for a day.
func Restart ¶
Restart replaces the current process with the binary at exePath, keeping PID, args, and environment — service supervisors never see an exit, so their restart policy doesn't matter.
func Rollback ¶
Rollback swaps the current binary with the backup kept by the last update and marks the replaced version as skipped so auto-update won't reinstall it. Returns the version rolled back to ("" when the backup predates manifests).
func RunWorker ¶
func RunWorker(current string)
RunWorker is the worker process body: refresh the release cache and, in auto-update mode, stage the new binary. Never prints; state files are the only output.
func SetSkipVersion ¶
func SetSkipVersion(version string)
SetSkipVersion records the version auto-update must not install; "" clears the skip.
func ShouldSpawnWorker ¶
ShouldSpawnWorker reports whether a background pass would do useful work: the daily check is due, or a known newer release still needs staging.
func SkipVersion ¶
func SkipVersion() string
SkipVersion returns the version auto-update must not install (set by a rollback), or "".
func SpawnWorker ¶
func SpawnWorker()
SpawnWorker relaunches this executable as a detached background process. Fire-and-forget: failures are silent, the next launch tries again.
func Stage ¶
Stage downloads and verifies the release binary for this platform and parks it in the staging area for a later ApplyStaged.
func StagedVersion ¶
func StagedVersion() string
StagedVersion returns the version waiting in the staging area, or "".