update

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 24 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 notifies, at most once a day, of a newer or deprecated release, and replaces a self-managed binary with a release from GitHub Releases on request.

Index

Constants

View Source
const (

	// SignerIdentity is the certificate identity of the release workflow, as in scripts/install.sh.
	SignerIdentity = `^https://github\.com/sepayvn/sepay-cli/\.github/workflows/release\.yml@refs/(heads/main|tags/v.*)$`

	// RequireSignatureEnv refuses an update without cosign, as it refuses an install in the scripts.
	RequireSignatureEnv = "SEPAY_REQUIRE_SIGNATURE"
)
View Source
const (
	// Package is the npm package; its latest dist-tag is the newest stable release.
	Package = "sepay-cli"
	// DisableEnv turns the check off.
	DisableEnv = "SEPAY_NO_UPDATE_NOTIFIER"
)

Variables

View Source
var ErrChecksum = errors.New("checksum mismatch")

ErrChecksum means a download does not match its SHA-256 in checksums.txt.

Functions

func Enabled

func Enabled() bool

Enabled reports whether a check may run: interactive stderr, not CI, not disabled, a release build.

func Newer added in v0.1.8

func Newer(a, b string) bool

Newer reports whether release a is newer than release b; false when either is not a version.

func Notice

func Notice(current string, r Result, exe string) string

Notice returns the stderr text for r, or "". exe, with symlinks resolved, tells the install channel.

func ReleaseNotesURL added in v0.1.8

func ReleaseNotesURL(version string) string

ReleaseNotesURL is the GitHub release page of version.

func RemoveOld added in v0.1.8

func RemoveOld(exe string)

RemoveOld deletes the executable a Windows update left beside exe. It fails silently while that file still runs.

func Replace added in v0.1.8

func Replace(exe, staged string) error

Replace puts the binary at staged in place of exe. A running Windows executable cannot be overwritten but can be renamed, so there exe moves to exe+".old" first; RemoveOld deletes it later.

func ValidVersion added in v0.1.8

func ValidVersion(v string) bool

ValidVersion reports whether v is a release version without the "v" of its tag, e.g. 0.2.0 or 0.2.0-rc.1.

Types

type Channel added in v0.1.8

type Channel string

Channel is how sepay was installed.

const (
	ChannelNPM      Channel = "npm"
	ChannelHomebrew Channel = "homebrew"
	ChannelScoop    Channel = "scoop"
	ChannelGo       Channel = "go"
	// ChannelStandalone is a binary from install.sh, install.ps1 or an archive unpacked by hand.
	ChannelStandalone Channel = "standalone"
)

The install channels. Only a standalone binary is replaced by "sepay update"; a package manager keeps its own record of what it installed, so it does the update.

func DetectChannel added in v0.1.8

func DetectChannel(exe string) Channel

DetectChannel reads the channel off exe, which must have its symlinks resolved: Homebrew and npm start sepay through one.

func (Channel) InstallCommand added in v0.1.8

func (ch Channel) InstallCommand(version string) string

InstallCommand is the command that installs exactly version through ch; "" when ch only installs its newest release.

func (Channel) Title added in v0.1.8

func (ch Channel) Title() string

Title names ch in a sentence.

func (Channel) UpdateCommand added in v0.1.8

func (ch Channel) UpdateCommand(current, latest string) string

UpdateCommand is the command that updates sepay through ch: to latest, or along the prerelease line of current when latest is "".

type Checker

type Checker struct {
	Client *http.Client
	// BaseURL is the package document URL ending in "/".
	BaseURL   string
	StatePath string
	Now       func() time.Time
}

Checker queries the registry and caches the answer.

func New

func New(configDir string) *Checker

New returns a Checker that caches its answer in configDir.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context, current string) (Result, error)

Check reports a newer release and deprecation, querying the registry at most once per interval.

type Result

type Result struct {
	Latest     string
	Deprecated string
	// Recommended is the release the registry points to when the running final release is
	// deprecated and nothing newer exists, i.e. the version to go back to.
	Recommended string
}

Result is what one check found; empty means nothing to say.

type Updater added in v0.1.8

type Updater struct {
	Client *http.Client
	// BaseURL is the releases URL ending in "/".
	BaseURL      string
	GOOS, GOARCH string
	// Cosign verifies checksums.txt against its signature and certificate; nil when cosign is not
	// installed, and then only the SHA-256 is checked.
	Cosign func(ctx context.Context, checksums, sig, cert string) error
	// Probe runs the unpacked binary and returns its version banner.
	Probe func(ctx context.Context, path string) (string, error)
}

Updater fetches a release of sepay for one platform from GitHub Releases.

func NewUpdater added in v0.1.8

func NewUpdater() *Updater

NewUpdater returns an Updater for the running platform.

func (*Updater) Archive added in v0.1.8

func (u *Updater) Archive(version string) string

Archive names the release archive of version for the Updater's platform.

func (*Updater) Fetch added in v0.1.8

func (u *Updater) Fetch(ctx context.Context, version, dir string) (string, error)

Fetch downloads version for this platform into dir, checks it against checksums.txt (and its signature when Cosign is set), unpacks the binary and probes it. It returns the path of the unpacked binary, inside dir so that Replace is a rename; on error nothing is left in dir.

func (*Updater) Latest added in v0.1.8

func (u *Updater) Latest(ctx context.Context) (string, error)

Latest returns the newest final release, read off the archive names in its checksums.txt, so no GitHub API call (and no API rate limit) is needed.

Jump to

Keyboard shortcuts

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