Documentation
¶
Overview ¶
Package github implements an updater.Provider backed by GitHub Releases.
The provider hits the standard releases API and selects an asset matching the running platform by filename heuristics. It supports public repos out of the box, private repos via a personal-access token, GitHub Enterprise via a base-URL override, and an optional sibling-asset checksums file for verification when the release publisher provides one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAssetMatcher ¶
func DefaultAssetMatcher(req updater.CheckRequest, assets []ReleaseAsset) int
DefaultAssetMatcher picks the first asset whose lowercase filename contains both the platform string AND the architecture string. Empty platform/arch matches everything. Optional .sig and checksum sidecars are skipped automatically.
Types ¶
type AssetMatcher ¶
type AssetMatcher func(req updater.CheckRequest, assets []ReleaseAsset) int
AssetMatcher returns the index of the asset (in releaseAssets) that should be downloaded for the supplied CheckRequest, or -1 to signal "no suitable asset on this release."
type Config ¶
type Config struct {
// Repository is "owner/repo". Required.
Repository string
// Token is an optional GitHub PAT. Required for private repos; for public
// repos it just raises the rate limit from 60 to 5000 req/hour.
Token string
// Prerelease, when true, walks /repos/{r}/releases (which includes
// prereleases) instead of /repos/{r}/releases/latest (which doesn't).
Prerelease bool
// BaseURL overrides https://api.github.com. Useful for GitHub Enterprise:
// pass "https://<host>/api/v3". Trailing slashes are trimmed.
BaseURL string
// AssetMatcher decides which asset is the right one for the running
// platform. Nil falls back to DefaultAssetMatcher.
AssetMatcher AssetMatcher
// ChecksumAsset, when non-empty, names a sibling asset (e.g.
// "checksums.txt" or "SHA256SUMS") the provider fetches and parses to
// populate Release.Verification. The default is no checksum lookup; the
// release ships unsigned and the framework warns at startup unless a
// Config.PublicKey is also provided for a separate signature scheme.
ChecksumAsset string
// HTTPClient lets callers inject a custom client. Nil uses a 30s-timeout
// client.
HTTPClient *http.Client
}
Config configures the GitHub provider.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements updater.Provider against the GitHub Releases API.
func New ¶
New returns a configured Provider. The only required field is Config.Repository ("owner/repo").
func (*Provider) Check ¶
Check implements updater.Provider. It resolves the latest release (or the latest including prereleases when Config.Prerelease is set), picks an asset matching the running platform, and decorates the Release with a Verification block when the publisher ships a checksum sidecar.