release

package
v0.7.114 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 11 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 release looks up the latest published advisor release. It only reads: it never downloads or replaces the binary.

Index

Constants

View Source
const (
	// ListURL is the unauthenticated GitHub endpoint for the newest published releases.
	ListURL = "https://api.github.com/repos/WoW-Companion/advisor/releases?per_page=30"
	// ChangelogURL is the CHANGELOG.md at a release tag; %s is the bare version.
	ChangelogURL = "https://raw.githubusercontent.com/WoW-Companion/advisor/v%s/CHANGELOG.md"
	// PullsURL is the pulled-version file on the main branch.
	PullsURL = "https://raw.githubusercontent.com/WoW-Companion/advisor/main/updates/updates.json"
	// SettleDelay is how long a release must have been public before it is offered, unless the
	// player asked for updates right away.
	SettleDelay = 24 * time.Hour
	// ListSize is how many other versions the Settings list shows beside the running one.
	ListSize = 5
)
View Source
const LatestURL = "https://api.github.com/repos/WoW-Companion/advisor/releases/latest"

LatestURL is the unauthenticated GitHub endpoint for the newest release.

Variables

This section is empty.

Functions

func BackTo added in v0.7.54

func BackTo(running string, rels []Rel, pulls Pulls) (string, bool)

BackTo is the version to go back to from a pulled running version: the pull's own back_to, or when that is missing or itself pulled, the newest older release that is not pulled.

func Changelog added in v0.7.58

func Changelog(ctx context.Context, client *http.Client, url, version string) (string, error)

Changelog reads CHANGELOG.md as it stood at the tag of a version. url has one %s for the version.

func Compare

func Compare(a, b string) (cmp int, ok bool)

Compare orders two dotted release numbers, ignoring a leading "v" and any "-suffix" or "+build" part. It returns ok=false when either is not made of numbers (a "dev" build).

Types

type Item added in v0.7.54

type Item struct {
	Version string `json:"version"`
	Date    string `json:"date"`
	Current bool   `json:"current,omitempty"`
}

Item is one row of the Settings version list.

type Notice added in v0.3.0

type Notice struct {
	Available bool   `json:"available"`
	Latest    string `json:"latest"`
}

Notice is what the overlay's version line needs: whether to say a newer release is available, and which. A failed lookup, a development build or a release that is not newer all read as no notice, so the line stays quiet.

func NoticeFor added in v0.3.0

func NoticeFor(res Result, err error) Notice

NoticeFor decides the update notice from a lookup's outcome.

type Options added in v0.7.54

type Options struct {
	Running   string
	Skipped   []string
	Immediate bool // "Get updates right away": no settle delay
	Now       time.Time
}

Options are the player's side of the offer rule.

type Pull added in v0.7.54

type Pull struct {
	Version string `json:"version"`
	Reason  string `json:"reason"`
	BackTo  string `json:"back_to"`
}

Pull is one pulled version: a release that must not be offered, and where to go back to.

type PulledRunning added in v0.7.54

type PulledRunning struct {
	Version string `json:"version"`
	Reason  string `json:"reason"`
	BackTo  string `json:"back_to"`
}

PulledRunning is what the red banner needs when the running version has been pulled.

type Pulls added in v0.7.54

type Pulls struct {
	Schema      int               `json:"schema"`
	Pulled      []Pull            `json:"pulled"`
	AddonPulled []json.RawMessage `json:"addon_pulled"`
	Notice      json.RawMessage   `json:"notice"`
	// Addon is addon_pulled read leniently: an entry that is not a usable object is dropped, never
	// an error. It has the same shape as a pulled app version.
	Addon []Pull `json:"-"`
}

Pulls is updates/updates.json.

func FetchPulls added in v0.7.54

func FetchPulls(ctx context.Context, client *http.Client, url string) Pulls

FetchPulls reads the pull file; any failure reads as nothing pulled.

func ParsePulls added in v0.7.54

func ParsePulls(b []byte) Pulls

ParsePulls reads the pull file. A file that cannot be parsed pulls nothing: a broken file must never block an update.

func (Pulls) Find added in v0.7.54

func (p Pulls) Find(version string) (Pull, bool)

Find is the pull entry for a version.

type Rel added in v0.7.54

type Rel struct {
	Version   string    // "0.7.53", with no leading "v"
	Published time.Time // published_at
	Body      string    // the release notes
}

Rel is one published release.

func Pick added in v0.7.54

func Pick(rels []Rel, pulls Pulls, o Options) (Rel, bool)

Pick is the release to offer: the newest one that is not pulled, not skipped, newer than the running version and at least SettleDelay old (no wait when Immediate). A development build has no comparable version and is offered nothing.

func Releases added in v0.7.54

func Releases(ctx context.Context, client *http.Client, url string) ([]Rel, error)

Releases reads the published, non-draft releases that carry the Windows installer.

type Result

type Result struct {
	Latest string // the release tag, for example "v0.1.0"
	Newer  bool   // Latest is newer than the running version
	Known  bool   // the running version is a release number that can be compared
}

Result is what a lookup found.

func Check

func Check(ctx context.Context, client *http.Client, url, current string) (Result, error)

Check asks url for the latest release and compares it with current.

type Source added in v0.7.54

type Source struct {
	Client            *http.Client
	ListURL, PullsURL string
	TTL               time.Duration // default 10 minutes
	// contains filtered or unexported fields
}

Source reads the release list and the pull file, and keeps the answer for a few minutes so the 4-hourly check, a wake-up and "Check now" together stay far inside GitHub's 60-an-hour limit.

func (*Source) Get added in v0.7.54

func (s *Source) Get(ctx context.Context, fresh bool) ([]Rel, Pulls, error)

Get returns the releases and the pulls. fresh skips the kept answer unless it is under 30 s old.

type Status added in v0.7.54

type Status struct {
	Available bool           `json:"available"`
	Latest    string         `json:"latest"`
	Published string         `json:"published,omitempty"`
	Notes     string         `json:"notes,omitempty"` // that version's CHANGELOG section; the caller fills it, never the release body
	Pulled    *PulledRunning `json:"pulled,omitempty"`
	Versions  []Item         `json:"versions,omitempty"`
}

Status is /api/update's answer. Available and Latest keep the shape of the older notice.

func Compute added in v0.7.54

func Compute(rels []Rel, pulls Pulls, o Options) Status

Compute turns the release list and the pull file into the overlay's update status.

Jump to

Keyboard shortcuts

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