Documentation
¶
Overview ¶
Package autoupdate installs newer stable GitHub releases over HTTPS and owns no host APIs.
Index ¶
Constants ¶
const DefaultSchedule = "50 4 * * *"
DefaultSchedule checks for updates daily at 04:50 local time.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Repository string // GitHub owner/repository.
CurrentVersion string // Actual running build identity, including development/dirty markers.
Binary string // Root archive member, including .exe on Windows.
ArchiveName func(version string) string // Exact asset basename; version has no leading v.
Client *http.Client // GitHub API only; never used for public archive downloads.
Log *slog.Logger // Required.
TaskName string // Windows launch context: task must use MultipleInstances Queue; empty means foreground.
}
Config identifies one application's release and current executable.
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule is an immutable parsed five-field maintenance schedule. Day-of-month and day-of-week constraints both apply.
func ParseSchedule ¶
ParseSchedule parses minute, hour, day-of-month, month and weekday fields. Fields support '*', integers, comma-separated lists, '*/N' and 'start/N'.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater serializes manual and scheduled installation for one running application. Hosts must share one instance and drain their resources before calling Restart.
func New ¶
New prepares an updater for the actual running executable. The application must own the executable directory. Call it even when scheduling is disabled: Windows startup removes the previous image left by a committed update. Development identities may discover releases but never replace the binary. Client authentication stays on api.github.com.
func (*Updater) Latest ¶
Latest returns the latest stable release identity, including for development builds.
func (*Updater) Restart ¶
Restart relaunches the executable with its original arguments and environment after the application has drained its workers, listeners and watchers. Unix replaces the process. On Windows, TaskName queues that task (which must use MultipleInstances Queue); otherwise it starts a foreground replacement child. The Windows caller must exit after Restart returns successfully.
func (*Updater) Run ¶
Run waits for local schedule occurrences until cancellation or a committed update. Each check adds an independent random delay from zero through five minutes. Failed checks are logged and retried on the next occurrence. The host owns graceful shutdown and must call Restart only after workers, listeners and watchers close.
func (*Updater) Update ¶
Update installs a strictly newer stable release and returns its version after commit, or an empty string when no installation is needed. Cancellation before commit leaves the executable unchanged; cancellation after commit does not undo it. Use an application-owned context, not a short-lived HTTP request context.