update

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package update checks for and installs new hopsesh releases from GitHub.

Trust, in layers:

  1. The archive must match checksums.txt from the same release (integrity).
  2. 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.
  3. 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

View Source
const Repo = "roeehrl/hopsesh"

Repo is the GitHub repository releases come from.

Variables

View Source
var API = "https://api.github.com"

API is the GitHub API base (tests point it elsewhere).

View Source
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.

View Source
var ErrNoReleases = errors.New("no hopsesh release is published yet")

ErrNoReleases means the repository has no published release (yet).

View Source
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

func ArchiveName(version string) string

ArchiveName is the release archive for this platform (matches .goreleaser.yaml).

func AssetName added in v0.3.0

func AssetName(t Target, version string) string

AssetName is the release file an update of t comes from (matches the release scripts).

func CLIFor added in v0.5.0

func CLIFor(ctx context.Context, rel *Release, goos, goarch string) ([]byte, error)

CLIFor downloads, from rel, the hopsesh program for another machine (goos, goarch), verified as an update is (checksums.txt and its signature), and returns it.

func CLIPath added in v0.3.0

func CLIPath(t Target) string

CLIPath is the hopsesh command-line program of an install.

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

func ManagedBy() (string, string)

ManagedBy names the package manager that owns the running program, with the command to update it, or "" when hopsesh may replace itself.

func Newer

func Newer(a, b string) bool

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

func Relaunch(t Target) error

Relaunch starts the app at t again (after an update), for the running one to quit.

func VerifySignature

func VerifySignature(data, sig []byte, pubB64 string) error

VerifySignature checks an ASN.1 ECDSA signature over data with a base64 PKIX key.

Types

type Kind added in v0.3.0

type Kind string

Kind is what an update replaces.

const (
	KindCLI        Kind = "cli"         // the hopsesh program
	KindMacApp     Kind = "mac-app"     // hopsesh.app, with the command-line tool inside
	KindWindowsApp Kind = "windows-app" // the folder with hopsesh-app.exe and hopsesh.exe
)

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.

func Latest

func Latest(ctx context.Context) (*Release, error)

Latest fetches the newest published release.

func Tagged added in v0.5.0

func Tagged(ctx context.Context, version string) (*Release, error)

Tagged fetches the release of one version (not only the newest).

type Target added in v0.3.0

type Target struct {
	Kind Kind
	Path string // the program, the .app bundle, or the Windows app's folder
}

Target is the install the running program belongs to.

func Current added in v0.3.0

func Current() (Target, error)

Current is the install the running program belongs to.

func Install

func Install(ctx context.Context, rel *Release) (Target, error)

Install downloads, verifies and installs rel over the install the running program belongs to (Current). It returns what it replaced: the program, the app or its folder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL