Documentation
¶
Overview ¶
Package selfupdate replaces the running binary with a release from GitHub, after it checks the keyless Sigstore signature of checksums.txt and the SHA-256 of the archive.
Index ¶
- Constants
- func AssetName(tag, goos, goarch string) string
- func Download(ctx context.Context, env Env, plan Plan) ([]byte, error)
- func Identity(tag string) string
- func Install(exe string, bin []byte, goos string) error
- func IsRelease(v string) bool
- func LatestTag(ctx context.Context, env Env) (string, error)
- func PackageManager(exe string) string
- func RemoveOld(exe string)
- func VerifySigstore(ctx context.Context, tag string, sums, bundleJSON []byte) error
- type Env
- type Plan
Constants ¶
const ( // Repo is the GitHub repository of the releases. Repo = "AlfrescoLabs/openarch-cli" // Issuer is the OIDC issuer of the release signature: GitHub Actions. Issuer = "https://token.actions.githubusercontent.com" // ChecksumsFile and BundleFile are release assets. ChecksumsFile = "checksums.txt" BundleFile = "checksums.txt.sigstore.json" )
Variables ¶
This section is empty.
Functions ¶
func Download ¶
Download fetches the archive of plan, checks the signature and the checksum, and returns the openarch binary from the archive.
func Identity ¶
Identity is the certificate identity of a release signature: the release workflow of Repo, running for tag.
func Install ¶
Install replaces exe with bin. The new file is written next to exe and then renamed, so exe is never half written. Windows cannot replace a running executable, so there the old one is first renamed to exe.old.
func IsRelease ¶
IsRelease reports whether v is a release version such as 0.2.0. Builds from source (dev, or git describe output such as v0.1.0-3-gabc1234) are not.
func LatestTag ¶
LatestTag returns the tag of the latest published release. It reads the redirect of /releases/latest, so it needs no GitHub API token.
func PackageManager ¶
PackageManager returns "brew" or "scoop" when exe was installed by one of them.
Types ¶
type Env ¶
type Env struct {
HTTP *http.Client
// BaseURL is https://github.com, or a test server.
BaseURL string
Executable func() (string, error)
GOOS string
GOARCH string
// Verify checks that bundleJSON is a valid signature of sums, made by the
// release workflow for tag.
Verify func(ctx context.Context, tag string, sums, bundleJSON []byte) error
}
Env gives the package access to the system. Tests replace its fields.