upgrade

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package upgrade implements self-update from GitHub releases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Upgrade

func Upgrade(current string, progress func(msg string)) (string, error)

Upgrade downloads and installs the latest release, replacing the running binary. It returns the new version tag on success.

It verifies provenance; UpgradeWithOptions is the form that can be told not to.

func UpgradeWithOptions added in v0.0.2

func UpgradeWithOptions(current string, opts Options, progress func(msg string)) (string, error)

UpgradeWithOptions is Upgrade with explicit control over verification.

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int64  `json:"size"`
}

Asset is a single file attached to a GitHub release.

type CheckResult

type CheckResult struct {
	Current         string
	Latest          string
	UpdateAvailable bool
	Release         *Release
}

CheckResult is the result of a version check.

func Check

func Check(current string) (*CheckResult, error)

Check compares current against the latest GitHub release tag and returns a CheckResult describing whether an update is available.

type Options added in v0.0.2

type Options struct {
	// SkipVerify installs without proving the archive's provenance.
	//
	// It exists for air-gapped mirrors that cannot reach Sigstore, and for
	// nothing else. It does not disable the checksum: that still runs, and
	// still proves only that the download arrived intact — checksums.txt is
	// served from the same release as the archive, so an attacker who can
	// replace one replaces the other.
	SkipVerify bool

	// Verifier overrides the provenance verifier. Tests set it.
	Verifier *provenance.Verifier
}

Options controls how an upgrade verifies what it is about to install.

The zero value verifies, deliberately: a security check whose default depends on a caller remembering to enable it is one that will eventually be forgotten at some call site nobody is looking at.

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	Name    string  `json:"name"`
	Assets  []Asset `json:"assets"`
}

Release represents a GitHub release response (subset of fields used).

func FetchLatestRelease

func FetchLatestRelease() (*Release, error)

FetchLatestRelease queries the GitHub releases API for the latest release.

Jump to

Keyboard shortcuts

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