upgrade

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractBinary

func ExtractBinary(r io.Reader, binaryName string) ([]byte, error)

ExtractBinary decompresses a tar.gz stream and extracts a single binary named binaryName. Returns the binary contents.

Safety guards:

  • Rejects entries with path traversal (../)
  • Accepts only a single file entry named binaryName
  • Caps decompressed size at 100MB

func NeedsUpgrade

func NeedsUpgrade(current, latestTag string) (isDevBuild bool, needsUpgrade bool)

NeedsUpgrade compares the current version against the latest release tag. Returns (isDevBuild, needsUpgrade). Dev builds return (true, false) — caller should skip upgrade. Equal versions return (false, false). Different versions return (false, true).

func ReplaceBinary

func ReplaceBinary(targetPath string, newContent []byte) error

ReplaceBinary atomically replaces the binary at targetPath with newContent.

func UpgradeBinary

func UpgradeBinary(ctx context.Context, release *github.RepositoryRelease, downloader AssetDownloader) error

UpgradeBinary downloads the release asset, verifies its GitHub digest, extracts the binary, and atomically replaces the current executable.

func UpgradeGoInstall

func UpgradeGoInstall(ctx context.Context) ([]byte, error)

UpgradeGoInstall runs `go install github.com/Naoray/scribe/cmd/scribe@latest`.

func UpgradeHomebrew

func UpgradeHomebrew(ctx context.Context, releaseTag string) ([]byte, error)

UpgradeHomebrew refreshes Homebrew metadata, runs `brew upgrade scribe`, and verifies the installed formula version matches releaseTag.

Types

type AssetDownloader

type AssetDownloader interface {
	DownloadReleaseAsset(ctx context.Context, owner, repo string, id int64) (io.ReadCloser, error)
	ReleaseAssetDigest(ctx context.Context, owner, repo string, id int64) (string, error)
}

AssetDownloader downloads a release asset by ID.

type Method

type Method int

Method represents how scribe was installed.

const (
	MethodHomebrew Method = iota
	MethodGoInstall
	MethodCurlBinary
)

func DetectMethod

func DetectMethod() Method

DetectMethod determines how scribe was installed by inspecting the executable path. Uses path heuristics first (instant), falls back to `brew list` for ambiguous paths.

func (Method) String

func (m Method) String() string

String returns a human-readable label for the install method.

Jump to

Keyboard shortcuts

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