Documentation
¶
Overview ¶
Package update checks GitHub for a newer WhatTheDock release and, when asked, downloads and installs it in place of the currently running binary. It mirrors two things that already exist elsewhere in this repo rather than inventing new conventions: the release asset naming (cmd/release's releaseBinaryName) and the download flow (scripts/install.sh) — both are whatthedock-<version>-<os>-<arch> fetched from a GitHub release's assets.
Index ¶
- Constants
- func AssetName(version string) string
- func DownloadURL(repo, version string) string
- func IsNewer(current, latest string) bool
- func LatestRelease(ctx context.Context, repo string) (string, error)
- func ReplaceRunningExecutable(ctx context.Context, repo, version string) (string, error)
- func SignatureAssetName(version string) string
- func SignatureDownloadURL(repo, version string) string
- func SigningKeyMatches(privKeyHex string) (bool, error)
Constants ¶
const Repo = "allisonhere/whatthedock"
Repo is the GitHub "owner/name" WhatTheDock releases are published under.
Variables ¶
This section is empty.
Functions ¶
func AssetName ¶
AssetName is the release asset filename for version on the current platform — must match cmd/release's releaseBinaryName exactly, since that's what actually names the uploaded asset.
func DownloadURL ¶
DownloadURL is the GitHub release asset URL for version.
func IsNewer ¶
IsNewer reports whether latest is a strictly newer vMAJOR.MINOR.PATCH version than current. Either string failing to parse in that shape (notably "dev", the ldflags default for a non-release build) always reports false — there's no sane "current" to compare against, so it's treated as never eligible for an update prompt rather than guessed at.
func LatestRelease ¶
LatestRelease fetches repo's latest published release tag (e.g. "v0.1.4") from the GitHub API.
func ReplaceRunningExecutable ¶
ReplaceRunningExecutable downloads version's release asset for repo, verifies it against the matching detached signature (see verify.go) before touching anything, and only then atomically replaces the currently running binary with it. It returns the executable's path so the caller can re-exec into it — this package never does that itself, since replacing a running process image is a main-package/process- lifecycle concern, not something a library package should reach for.
func SignatureAssetName ¶ added in v0.1.12
SignatureAssetName is the detached-signature asset filename cmd/release publishes alongside AssetName's binary — see verify.go.
func SignatureDownloadURL ¶ added in v0.1.12
SignatureDownloadURL is the GitHub release asset URL for version's detached signature.
func SigningKeyMatches ¶ added in v0.1.27
SigningKeyMatches reports whether privKeyHex (the hex ed25519 private key cmd/release signs with) corresponds to the public key this package bakes in. The release tool calls it as a preflight so a drifted or rotated key is caught before a build+sign, instead of producing a binary every installed app would reject. A malformed key is an error, not merely false.
Types ¶
This section is empty.