Documentation
¶
Overview ¶
Package updater checks for new Roger releases and self-updates the binary.
Index ¶
- Variables
- func AssetName(version string) string
- func FindAsset(rel *Release) (string, error)
- func FindChecksums(rel *Release) (string, error)
- func IsNewer(current, available string) bool
- func Rollback() error
- func SaveState(s *CheckState) error
- func ShouldCheck(s *CheckState, interval time.Duration) bool
- func StartupCheck(ctx context.Context, currentVersion string) <-chan string
- func Update(ctx context.Context, currentVersion string) (string, error)
- type Asset
- type CheckState
- type Release
Constants ¶
This section is empty.
Variables ¶
var ( GitHubOwner = "EMSERO" GitHubRepo = "roger" )
GitHubOwner and GitHubRepo are the GitHub coordinates for release checks.
var StateDir string
StateDir can be set to override where update state is stored. If empty, falls back to ~/.roger/state/ (legacy).
Functions ¶
func FindChecksums ¶
FindChecksums returns the download URL for checksums.txt.
func IsNewer ¶
IsNewer returns true if the available version is newer than current. Compares semver strings (v0.4.0 > v0.3.0). Falls back to string comparison.
func Rollback ¶
func Rollback() error
Rollback restores the previous binary from the .bak file created during updates.
func ShouldCheck ¶
func ShouldCheck(s *CheckState, interval time.Duration) bool
ShouldCheck returns true if enough time has elapsed since the last check.
func StartupCheck ¶
StartupCheck runs a non-blocking background version check. Returns a channel that receives a message if an update is available.
Types ¶
type Asset ¶
type Asset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
}
Asset is a single file attached to a GitHub release.
type CheckState ¶
type CheckState struct {
LastCheckedAt time.Time `json:"lastCheckedAt"`
LastAvailableVersion string `json:"lastAvailableVersion"`
LastNotifiedVersion string `json:"lastNotifiedVersion"`
}
CheckState persists the last version check result.
func LoadState ¶
func LoadState() (*CheckState, error)
LoadState reads the last check state from disk.