update

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package update fetches signed codexctl releases from GitHub and replaces the running executable.

Index

Constants

View Source
const (
	Repo = "AbdelrhmanSaid/codexctl"
)

Variables

This section is empty.

Functions

func Apply

func Apply(exe string, binary []byte) error

Apply renames the new file into place, which is atomic on POSIX. On Windows the old file is moved aside first.

func AssetName

func AssetName(version string) string

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions sorts a prerelease before its release.

func DecodePrivateKey

func DecodePrivateKey(encoded string) (ed25519.PrivateKey, error)

func DecodePublicKey

func DecodePublicKey(encoded string) (ed25519.PublicKey, error)

func Executable

func Executable() (string, error)

Executable follows symlinks, such as one from a manual install into ~/bin.

func ExtractBinary

func ExtractBinary(archive []byte, name string) ([]byte, error)

func GenerateKey

func GenerateKey() (public, private string, err error)

GenerateKey returns the public key embedded in the binary and the private key kept as a CI secret.

func PublicKey

func PublicKey() (ed25519.PublicKey, error)

func Remove added in v0.3.0

func Remove(exe string) error

Remove can unlink a running program's file on POSIX.

func Sign

func Sign(key ed25519.PrivateKey, data []byte) []byte

func Verify

func Verify(key ed25519.PublicKey, data, signature []byte) error

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	PublicKey ed25519.PublicKey
	// ReleasesURL is pointed elsewhere by tests.
	ReleasesURL string
	// Progress gets a total of -1 when it is unknown.
	Progress func(done, total int64)
}

func NewClient

func NewClient(currentVersion string) (*Client, error)

func (*Client) Download

func (c *Client) Download(ctx context.Context, release *Release) ([]byte, error)

func (*Client) Latest

func (c *Client) Latest(ctx context.Context) (*Release, error)

Latest follows GitHub's latest/download redirect, so no API call is involved.

func (*Client) Version

func (c *Client) Version(ctx context.Context, version string) (*Release, error)

type Method

type Method int
const (
	MethodRelease Method = iota // a GoReleaser build placed on PATH by hand
	MethodGoInstall
	MethodPackage // dpkg, rpm, apk or pacman
	MethodDev     // go build in a checkout
)

func DetectInstall

func DetectInstall(releaseBuild bool, exe string) Method

DetectInstall takes whether GoReleaser stamped a version into the binary.

type Release

type Release struct {
	Version   string            // without the leading "v"
	Checksums map[string]string // asset file name -> hex SHA-256
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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