upgrade

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 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.

func FetchRelease added in v0.0.3

func FetchRelease(tag string) (*Release, error)

FetchRelease queries the GitHub releases API for one release by tag.

Separate from FetchLatestRelease because a fleet upgrade is usually *to a named version* rather than to whatever is newest: an operator rolling a hundred devices forward wants them to land on the same build, and "latest" evaluated once per device is not that — a release published midway through the rollout would split the fleet across two versions.

type Staged added in v0.0.3

type Staged struct {
	// Tag is the release this came from, resolved — so a caller that asked
	// for "latest" learns what latest meant.
	Tag string
	// BinaryPath is the extracted cloop executable.
	BinaryPath string
	// AssetName is the release archive the binary came out of.
	AssetName string
	// ProvenanceVerified records that the archive's signature was checked
	// against cloop's pinned release identity. False only when the caller
	// passed Options.SkipVerify.
	ProvenanceVerified bool
}

Staged describes a release that has been fetched, verified and written to disk, but not installed.

func StageRelease added in v0.0.3

func StageRelease(tag, destDir string, opts Options, progress func(string)) (Staged, error)

StageRelease downloads the release for tag, proves it came from cloop's release workflow, and extracts the binary into destDir.

It returns before anything is installed. The caller is responsible for destDir's lifetime; a staged binary left behind is an executable nobody is watching, so callers that stage into a temporary directory should remove it.

Jump to

Keyboard shortcuts

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