Documentation
¶
Overview ¶
Package selfupdate implements grant's self-update: GitHub release discovery, platform asset selection, SHA-256 checksum verification and archive extraction, with the binary replacement itself delegated to github.com/minio/selfupdate.
Trust model: checksums.txt is published by GoReleaser alongside the archives and is fetched from the same origin as the binary. Verifying it protects against truncated or corrupted downloads and CDN/transport tampering. It does NOT protect against a compromised GitHub account or release pipeline, since an attacker able to replace the archive can also replace checksums.txt.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
CompareVersions parses both versions and compares them by SemVer precedence.
func InterruptedUpdate ¶
InterruptedUpdate reports whether targetPath looks like a previous update that was interrupted between the two renames - the binary is missing but its backup is still there - and returns the command that repairs it.
Types ¶
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater checks GitHub Releases and replaces the running binary.
func New ¶
New creates an Updater for the given "owner/repo" slug. version is the running build's version, used only for the User-Agent; an empty value becomes "dev".
func (*Updater) UpdateSelf ¶
func (u *Updater) UpdateSelf(ctx context.Context, current string) (newVersion string, updated bool, err error)
UpdateSelf checks for a newer release and, if one exists, downloads, verifies and installs it. It returns the latest published version, whether the binary was replaced, and any error.
type Version ¶
type Version struct {
Major int
Minor int
Patch int
// Prerelease is the dot-separated pre-release string without the leading
// "-" (empty when the version is a normal release).
Prerelease string
// Build is the build metadata without the leading "+". It never affects
// ordering.
Build string
}
Version is a Semantic Versioning 2.0.0 version.
GoReleaser normally emits plain MAJOR.MINOR.PATCH tags, but it can also produce pre-release (`1.2.3-rc.1`) and build-metadata (`1.2.3+build.5`) tags, and grant must be able to update from such a build. Ordering follows SemVer precedence: build metadata is ignored, and a pre-release sorts before its corresponding release.
func ParseVersion ¶
ParseVersion parses a SemVer 2.0.0 version. A leading "v" or "V" is tolerated, since Git tags conventionally carry one and GitHub reports the tag verbatim.