update

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package update provides self-update functionality for engram.

Index

Constants

View Source
const (
	GitHubRepo       = "thebtf/engram"
	ReleasesAPI      = "https://api.github.com/repos/" + GitHubRepo + "/releases/latest"
	CheckInterval    = 24 * time.Hour
	MaxExtractedSize = 250 * 1024 * 1024 // 250MB max per extracted file
	RestartDelay     = 500 * time.Millisecond
)
View Source
const InstallScriptURL = "https://raw.githubusercontent.com/" + GitHubRepo + "/main/scripts/install.sh"

InstallScriptURL is the URL to the remote installation script.

Variables

This section is empty.

Functions

func GetManualUpdateCommand

func GetManualUpdateCommand(version string) string

GetManualUpdateCommand returns the curl command for manual update. If version is empty, it installs the latest version.

Types

type Asset

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

Asset represents a release asset.

type Release

type Release struct {
	PublishedAt time.Time `json:"published_at"`
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Body        string    `json:"body"`
	Assets      []Asset   `json:"assets"`
}

Release represents a GitHub release.

type UpdateInfo

type UpdateInfo struct {
	PublishedAt         time.Time `json:"published_at,omitempty"`
	CurrentVersion      string    `json:"current_version"`
	LatestVersion       string    `json:"latest_version"`
	ReleaseNotes        string    `json:"release_notes,omitempty"`
	DownloadURL         string    `json:"download_url,omitempty"`
	ChecksumsURL        string    `json:"checksums_url,omitempty"`
	BundleURL           string    `json:"bundle_url,omitempty"`
	ManualUpdateCommand string    `json:"manual_update_command,omitempty"`
	Available           bool      `json:"available"`
}

UpdateInfo contains information about an available update.

type UpdateStatus

type UpdateStatus struct {
	State               string  `json:"state"`
	Message             string  `json:"message"`
	Error               string  `json:"error,omitempty"`
	ManualUpdateCommand string  `json:"manual_update_command,omitempty"`
	Progress            float64 `json:"progress"`
}

UpdateStatus represents the current update status.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater handles self-updates.

func New

func New(currentVersion, installDir string) *Updater

New creates a new Updater.

func (*Updater) ApplyUpdate

func (u *Updater) ApplyUpdate(ctx context.Context, info *UpdateInfo) error

ApplyUpdate downloads and applies the update.

func (*Updater) CheckForUpdate

func (u *Updater) CheckForUpdate(ctx context.Context) (*UpdateInfo, error)

CheckForUpdate checks if a new version is available.

func (*Updater) GetStatus

func (u *Updater) GetStatus() UpdateStatus

GetStatus returns the current update status.

func (*Updater) Restart

func (u *Updater) Restart() error

Restart spawns the new worker binary and exits the current process. This should be called after a successful update to apply the new version.

Jump to

Keyboard shortcuts

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