update

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package update tells the operator a newer orch is out, and replaces the binary on request (`orch upgrade`).

Releases ship daily at times, so a user has to be told. The check is one unauthenticated read of GitHub's releases API at most once a day, cached in ~/.orch; nothing about the user or the project is sent. A release whose notes carry CriticalMarker is critical: `orch run` and `orch dashboard` refuse to start on an older version until the user upgrades or says to go ahead anyway.

Index

Constants

View Source
const (
	// Repo is where orch is released.
	Repo = "Guria-Studio/orch"
	// CriticalMarker, anywhere in a release's notes, makes it critical.
	CriticalMarker = "<!-- orch:critical -->"
	// DisableEnv turns the check, the notice and the critical gate off.
	DisableEnv = "ORCH_NO_UPDATE_CHECK"
	// MaxAge is how long a check is trusted before GitHub is asked again.
	MaxAge = 24 * time.Hour
)

Variables

This section is empty.

Functions

func AssetName

func AssetName(tag, goos, goarch string) string

AssetName is the archive goreleaser publishes for one platform.

func CLIBehind

func CLIBehind(installed, latest string) bool

CLIBehind reports whether installed is older than latest; either one without a version in it is not behind.

func CLIVersionsPath

func CLIVersionsPath() (string, error)

CLIVersionsPath is where the CLIs' latest versions are remembered: ~/.orch/cli-versions.json.

func CachePath

func CachePath() (string, error)

CachePath is where checks are remembered: ~/.orch/update-check.json.

func Highlights

func Highlights(body string, max int) []string

Highlights returns the first max list items of release notes, as plain one-line text: emphasis dropped, GitHub's generated "by @x in <PR URL>" shortened to "(#N)", long items cut. Notes with no list give none.

func IsRelease

func IsRelease(version string) bool

IsRelease reports whether version is a release tag, not a dev build.

func LatestCLI

func LatestCLI(ctx context.Context, r Registry, path, pkg string, now time.Time) (string, error)

LatestCLI is pkg's latest version, from the cache at path while it is younger than MaxAge and from the registry otherwise. Like Check, a failed read returns the last known version with the error and is still recorded, so an offline machine waits out the timeout once a day, not every command.

func Less

func Less(a, b string) bool

Less reports whether release tag a is older than b. Unparseable tags sort first.

func LooseVersion

func LooseVersion(s string) (string, bool)

LooseVersion is the first x.y.z in s, whatever surrounds it: a CLI's `--version` says "codex-cli 0.154.0" or "2.1.310 (Claude Code)".

func ManagedBy

func ManagedBy(path string) string

ManagedBy names the package manager that owns the binary at path, or "" when orch was installed by hand or by install.sh. A managed binary is upgraded through its manager; replacing it underneath would desync it.

func Notice

func Notice(current string, newer []Release) string

Notice is what a user on current reads about newer, or "" when there is nothing newer.

func Replace

func Replace(target string, binary []byte) error

Replace swaps the binary at target for binary: written next to it first, then renamed over it, so an interrupted upgrade never leaves half a binary where orch was. A running process keeps the old file it already opened.

Types

type Client

type Client struct {
	HTTP *http.Client
	// API is GitHub's API root; empty means api.github.com.
	API string
}

Client reads orch's releases.

func (Client) Releases

func (c Client) Releases(ctx context.Context) ([]Release, error)

Releases lists the published Go releases for this OS and architecture, newest first. Drafts, pre-releases and the Python line's tags are left out: none of them has a binary `orch upgrade` could install.

type Downloader

type Downloader struct {
	HTTP *http.Client
	// Base is where release files are served from; empty means GitHub.
	Base string
}

Downloader fetches release archives.

func (Downloader) Binary

func (d Downloader) Binary(ctx context.Context, tag, goos, goarch string) ([]byte, error)

Binary downloads tag's archive for goos/goarch, checks it against the release's checksums.txt, and returns the orch binary inside it. Nothing is trusted without its checksum: a truncated or tampered download never reaches the disk.

type Registry

type Registry struct {
	HTTP *http.Client
	// URL is the registry's root; empty means registry.npmjs.org.
	URL string
}

Registry reads the latest version of an npm package.

func (Registry) Latest

func (r Registry) Latest(ctx context.Context, pkg string) (string, error)

Latest is the version the package's `latest` dist-tag points at.

type Release

type Release struct {
	Tag      string `json:"tag"`
	URL      string `json:"url"`
	Critical bool   `json:"critical"`
	// Highlights are the first items of the release notes, one line each.
	Highlights []string `json:"highlights"`
	// Notes are the release notes whole, as Markdown, and PublishedAt when
	// the release went out: what the dashboard's What's new page shows.
	Notes       string `json:"notes"`
	PublishedAt string `json:"published_at"`
}

Release is one Go release of orch, as the notice needs it.

func Check

func Check(ctx context.Context, c Client, path string, now time.Time) ([]Release, error)

Check returns orch's releases, from the cache at path while it is younger than MaxAge and from GitHub otherwise. When GitHub cannot be reached the last known releases are returned with the error, and the attempt is still recorded: offline, every command would otherwise wait out the timeout.

func Critical

func Critical(newer []Release) (Release, bool)

Critical returns the newest critical release among newer, if any.

func Newer

func Newer(releases []Release, current string) []Release

Newer returns the releases newer than current, newest first. A current that is not a release tag has nothing to compare against: nil.

Jump to

Keyboard shortcuts

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