update

package
v1.11.0 Latest Latest
Warning

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

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

Documentation

Overview

Package update implements self-update for evva.

It fetches the latest GitHub Release, compares versions, downloads the correct binary asset for the current OS/arch, and replaces the running binary atomically — no Go toolchain required.

Index

Constants

View Source
const (
	DefaultOwner = "johnny1110"
	DefaultRepo  = "evva"
)

defaults for the bundled evva binary.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, release *Release) (string, error)

Apply downloads the appropriate asset for the current OS/arch from the release, decompresses it, and replaces the currently running binary. Returns the path to the replaced binary.

On Unix the replacement is atomic (os.Rename on the same filesystem). On Windows the running image cannot be overwritten but CAN be renamed: it is moved aside to "<exe>.old" and the new binary takes its place — the leftover .old is swept by CleanupOld at the next start.

func CleanupOld added in v1.7.0

func CleanupOld()

CleanupOld removes the "<exe>.old" leftover a Windows self-update leaves behind (replaceBinary renames the running image aside; only a LATER process can delete it). Call early at startup. No-op when absent and harmless on unix, where Apply never creates one.

func CurrentVersion

func CurrentVersion() string

CurrentVersion returns the ldflags-injected version string. Falls back to the compile-time default when ldflags weren't set (dev builds, go run).

Types

type Asset

type Asset struct {
	Name        string // e.g. "evva-darwin-arm64.tar.gz"
	DownloadURL string // browser_download_url
	Size        int64  // bytes
}

Asset is a single downloadable file attached to a release.

type Release

type Release struct {
	Version string  // tag name, e.g. "v0.2.0"
	URL     string  // HTML URL of the release page
	Assets  []Asset // downloadable assets
}

Release represents a GitHub Release with its downloadable assets.

func Check

func Check(ctx context.Context, owner, repo string) (*Release, error)

Check fetches the latest release from GitHub for owner/repo and returns it. If the latest tag matches currentVersion, the release is still returned so the caller can decide what "up-to-date" means (exact match vs newer).

"Latest" follows GitHub's own designation: stable releases on main carry the Latest badge, while beta releases on pre-release are published as pre-releases and are excluded — so `evva update` lands on the newest stable.

func CheckTag added in v1.4.4

func CheckTag(ctx context.Context, owner, repo, tag string) (*Release, error)

CheckTag fetches a specific release by its exact tag (e.g. "v1.4.3" or "v1.4.3-beta.1") for owner/repo. It backs `evva update <version>`, letting a caller pin to an exact build — including a pre-release beta — rather than the latest stable. The returned release is fed to Apply unchanged.

Jump to

Keyboard shortcuts

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