update

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 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 replaces the executable at exe with binary. The new file is written next to the old one and renamed over it, so the swap is atomic on POSIX. Windows refuses to overwrite a running executable but allows renaming it, so the old file is moved aside first and deleted on a later update.

func AssetName

func AssetName(version string) string

AssetName is the archive GoReleaser publishes for this platform.

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions orders two semantic versions, ignoring a leading "v". A prerelease sorts before the release it precedes.

func DecodePrivateKey

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

func DecodePublicKey

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

func Executable

func Executable() (string, error)

Executable returns the real path of the running binary, following any symlink such as the one a manual install into ~/bin might use.

func ExtractBinary

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

ExtractBinary returns the codexctl executable stored in a release archive.

func GenerateKey

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

GenerateKey creates a new signing key pair. Both halves are base64 strings: the public key is embedded in the binary and the private key is stored as a CI secret.

func PublicKey

func PublicKey() (ed25519.PublicKey, error)

PublicKey returns the embedded release verification key.

func Sign

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

Sign returns a detached signature for data as a single base64 line.

func Verify

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

Verify checks a detached signature produced by Sign.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	PublicKey ed25519.PublicKey
	// ReleasesURL is the GitHub releases page; tests point it elsewhere.
	ReleasesURL string
}

func NewClient

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

func (*Client) Download

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

Download fetches this platform's archive and verifies its checksum.

func (*Client) Latest

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

Latest resolves the newest non-prerelease. GitHub redirects the latest/download path, so no API call or rate limit is involved.

func (*Client) Version

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

Version resolves one specific release.

type Method

type Method int

Method describes how the running binary was installed.

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 classifies the running binary. releaseBuild reports whether GoReleaser stamped a version into it.

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
}

Release is one published version and the checksums of its assets.

Jump to

Keyboard shortcuts

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