Documentation
¶
Index ¶
- func ExtractBinary(r io.Reader, binaryName string) ([]byte, error)
- func NeedsUpgrade(current, latestTag string) (isDevBuild bool, needsUpgrade bool)
- func ReplaceBinary(targetPath string, newContent []byte) error
- func UpgradeBinary(ctx context.Context, release *github.RepositoryRelease, ...) error
- func UpgradeGoInstall(ctx context.Context) ([]byte, error)
- func UpgradeHomebrew(ctx context.Context, releaseTag string) ([]byte, error)
- type AssetDownloader
- type Method
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractBinary ¶
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 ¶
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 ¶
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 ¶
UpgradeGoInstall runs `go install github.com/Naoray/scribe/cmd/scribe@latest`.
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.