selfupdate

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package selfupdate implements a cryptographically secured self-update mechanism which fetches binaries via GitHub's API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAndVerifyRelease

func DownloadAndVerifyRelease(ctx context.Context, rel *Release, target string, logger *log.Logger) error

DownloadAndVerifyRelease downloads a released version of cunīcu and saves it to target. It returns the version string for the newest version. The function printf is used to print progress information.

func GPGVerify

func GPGVerify(data, sig []byte) (ok bool, err error)

GPGVerify checks the authenticity of data by verifying the signature sig, which must be ASCII armored (base64). When the signature matches, GPGVerify returns true and a nil error.

func VersionVerify added in v0.1.3

func VersionVerify(binaryFile, expectedVersion string) error

Types

type Asset

type Asset struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

Asset is a file uploaded and attached to a release.

type Release

type Release struct {
	Name        string    `json:"name"`
	TagName     string    `json:"tag_name"`
	Draft       bool      `json:"draft"`
	PreRelease  bool      `json:"prerelease"` //nolint:tagliatelle
	PublishedAt time.Time `json:"published_at"`
	Assets      []Asset   `json:"assets"`

	Version string `json:"-"` // set manually in the code
}

Release collects data about a single release on GitHub.

func GitHubLatestRelease

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

GitHubLatestRelease uses the GitHub API to get information about the latest release of a repository.

func SelfUpdate added in v0.2.1

func SelfUpdate(output string, logger *log.Logger) (*Release, error)

func (Release) String

func (r Release) String() string

Jump to

Keyboard shortcuts

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