Documentation
¶
Overview ¶
Package update checks for and installs new hopsesh releases from GitHub.
Trust, in layers:
- The archive must match checksums.txt from the same release (integrity).
- Release builds embed an ECDSA P-256 public key (PublicKey, set with -ldflags); checksums.txt must then carry a valid signature (checksums.txt.sig, ASN.1 DER, made with `openssl dgst -sha256 -sign`). This holds even if the GitHub account or a CDN were compromised. Builds without a key can check but not install.
- On macOS, when the running program is code-signed, the new one must be signed by the same team (and an app must pass Gatekeeper, so it is notarized).
What is replaced follows what is running: the command-line tool, the macOS app (the whole hopsesh.app, from the release's disk image) or the Windows app (hopsesh-app.exe and hopsesh.exe together, from the release's app zip). Copies installed by Homebrew, Scoop or winget are left to those.
Index ¶
- Constants
- Variables
- func ArchiveName(version string) string
- func AssetName(t Target, version string) string
- func CLIPath(t Target) string
- func CleanUp()
- func ManagedBy() (string, string)
- func Newer(a, b string) bool
- func Relaunch(t Target) error
- func VerifySignature(data, sig []byte, pubB64 string) error
- type Kind
- type Release
- type Target
Constants ¶
const Repo = "roeehrl/hopsesh"
Repo is the GitHub repository releases come from.
Variables ¶
var API = "https://api.github.com"
API is the GitHub API base (tests point it elsewhere).
var ErrNoKey = errors.New("this build has no release signing key, so it cannot verify and install updates; reinstall from a release")
ErrNoKey means this build has no release key, so it will not install updates.
var ErrNoReleases = errors.New("no hopsesh release is published yet")
ErrNoReleases means the repository has no published release (yet).
var PublicKey = ""
PublicKey is the base64 DER (PKIX) ECDSA P-256 key release builds embed:
-X github.com/roeehrl/hopsesh/internal/update.PublicKey=MFkw...
Functions ¶
func ArchiveName ¶
ArchiveName is the release archive for this platform (matches .goreleaser.yaml).
func AssetName ¶ added in v0.3.0
AssetName is the release file an update of t comes from (matches the release scripts).
func CleanUp ¶ added in v0.3.0
func CleanUp()
CleanUp removes what an earlier update left behind: the programs Windows moved aside, and a macOS update's work folder. Best effort; call it at start-up.
func ManagedBy ¶
ManagedBy names the package manager that owns the running program, with the command to update it, or "" when hopsesh may replace itself.
func Newer ¶
Newer reports whether version a is newer than b (semantic versions, "v" optional; a development build is never newer and is always older than a release).
func Relaunch ¶ added in v0.3.0
Relaunch starts the app at t again (after an update), for the running one to quit.
func VerifySignature ¶
VerifySignature checks an ASN.1 ECDSA signature over data with a base64 PKIX key.
Types ¶
type Release ¶
type Release struct {
Tag string `json:"tag"`
Version string `json:"version"`
URL string `json:"url"`
Assets map[string]string `json:"-"` // name → download URL
}
Release is the latest release's relevant parts.