stdxgit.sr.ht/~pingoo/stdx/selfupdate Index | Files

package selfupdate

import "git.sr.ht/~pingoo/stdx/selfupdate"

Index

Constants

const (
	DefaultUserAgent = "Mozilla/5.0 (compatible; +https://git.sr.ht/~pingoo/stdx/selfupdate)"
)

Types

type ChannelManifest

type ChannelManifest struct {
	Name    string `json:"name"`
	Channel string `json:"channel"`
	Version string `json:"version"`
}

func (ChannelManifest) ToJson

func (manifest ChannelManifest) ToJson() (manifestJSON []byte, err error)

type Config

type Config struct {
	ZingPublicKey string
	// BaseURL is the URL of the folder containing the manifest
	// e.g. https://downloads.example.com/myapp
	BaseURL        string
	CurrentVersion string
	ReleaseChannel string

	// Default: 300 seconds
	AutoupdateInterval int64
	// Verbose logs actions with the INFO level
	Verbose    bool
	UserAgent  *string
	HttpClient *http.Client
}

type CreateReleaseInput

type CreateReleaseInput struct {
	// Name of the project. e.g. myapp
	Name string
	// Version of the release of the project. e.g. 1.1.52
	Version string
	Channel string
	Files   []string
	// ZignPrivateKey is the base64 encoded zign privateKey, encrypted with password
	ZignPrivateKey string
	ZignPassword   string
}

type Release

type Release struct {
	Name            string
	ChannelManifest ChannelManifest
	ZignManifest    zign.Manifest
}

func CreateRelease

func CreateRelease(ctx context.Context, info CreateReleaseInput) (release Release, err error)

type Updater

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

func NewUpdater

func NewUpdater(config Config) (updater *Updater, err error)

func (*Updater) CheckUpdate

func (updater *Updater) CheckUpdate(ctx context.Context) (manifest ChannelManifest, err error)

func (*Updater) RestartRequired

func (updater *Updater) RestartRequired() bool

func (*Updater) RunAutoupdateInBackground

func (updater *Updater) RunAutoupdateInBackground(ctx context.Context)

func (*Updater) Update

func (updater *Updater) Update(ctx context.Context, channelManifest ChannelManifest) (err error)

func (*Updater) UpdateAvailable

func (updater *Updater) UpdateAvailable() bool

UpdateAvailable returns true if the latest avaiable version is > to the latest install version

Source Files

autoupdate.go channel.go const.go relaese.go update.go updater.go

Version
v0.0.0-20240218134121-094174641f6e (latest)
Published
Feb 18, 2024
Platform
linux/amd64
Imports
24 packages
Last checked
4 months ago

Tools for package owners.