selfupdate

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelStable = "stable"
	ChannelRC     = "rc"
)

Update channels. GitHub's /releases/latest already excludes prereleases, so the stable channel needs no filtering; the rc channel scans the release list and accepts release candidates.

Variables

View Source
var AllowedDownloadPrefixes = []string{
	"https://github.com/",
	"https://api.github.com/",
}

AllowedDownloadPrefixes controls which URL prefixes are accepted by DownloadAsset. Exported for test injection only.

View Source
var ReleaseListURL = "https://api.github.com/repos/brandyn-s/code-graph/releases?per_page=20"

ReleaseListURL lists recent releases including prereleases. Exported for test injection. Used only on the "rc" update channel.

View Source
var ReleaseURL = "https://api.github.com/repos/brandyn-s/code-graph/releases/latest"

ReleaseURL is the GitHub API endpoint for latest release. Exported for test injection.

Points at this fork, NOT upstream DeusData — `code-graph update` replaces the running binary with whatever this URL serves, and an upstream binary would silently drop every fork addition (security tools, resolver gates, SCIP ingest). See tools.releaseURL for the matching update-notice endpoint.

Functions

func AssetName

func AssetName() string

AssetName returns the expected release asset name for the current platform.

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions compares two semver strings (e.g. "0.2.1" vs "0.2.0"). Returns >0 if a > b, <0 if a < b, 0 if equal.

func DownloadAsset

func DownloadAsset(ctx context.Context, rawURL string) ([]byte, error)

DownloadAsset downloads a release asset and returns the full body as bytes. The response body is fully read before returning to avoid premature context cancellation.

func DownloadChecksums

func DownloadChecksums(ctx context.Context, release *Release) (map[string]string, error)

DownloadChecksums downloads and parses the checksums.txt file from a release. Returns a map of filename → hex-encoded SHA-256 hash.

func NormalizeChannel

func NormalizeChannel(raw string) string

NormalizeChannel maps a raw CODE_GRAPH_UPDATE_CHANNEL value to a channel. Unknown values fall back to stable so a typo never opts into prereleases.

func VerifyReleaseAsset

func VerifyReleaseAsset(
	ctx context.Context,
	releaseTag string,
	assetName string,
	archive []byte,
) error

VerifyReleaseAsset proves that archive is the named immutable release asset and, for releases that publish provenance, that it has a valid SLSA attestation. Verification is performed against a private temporary copy so the exact downloaded bytes are checked before extraction or replacement.

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int64  `json:"size"`
}

Asset holds a single release artifact.

type Release

type Release struct {
	TagName    string  `json:"tag_name"`
	Assets     []Asset `json:"assets"`
	Prerelease bool    `json:"prerelease"`
	Draft      bool    `json:"draft"`
}

Release holds parsed GitHub release metadata.

func FetchLatestRelease

func FetchLatestRelease(ctx context.Context) (*Release, error)

FetchLatestRelease fetches release metadata from GitHub.

func FetchNewestRelease

func FetchNewestRelease(ctx context.Context, channel string) (*Release, error)

FetchNewestRelease returns the newest release visible on the channel: GitHub's latest non-prerelease on stable, or the highest version among published (non-draft) releases including release candidates on rc.

func FetchRelease

func FetchRelease(ctx context.Context, rawURL string) (*Release, error)

FetchRelease fetches release metadata, authenticating access through GitHub CLI while retaining HTTP injection for generic/public URLs.

func (*Release) FindAsset

func (r *Release) FindAsset(name string) *Asset

FindAsset finds a release asset by name.

func (*Release) LatestVersion

func (r *Release) LatestVersion() string

LatestVersion returns the version string from the latest release (without "v" prefix).

Jump to

Keyboard shortcuts

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