release

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 9 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 release queries GitHub Releases and applies the SemVer channel policy.

Index

Constants

View Source
const (

	// CacheFilename 是 release cache 使用的固定文件名。
	CacheFilename = "github-releases.json"
)

Variables

This section is empty.

Functions

func ValidateOfficialGitHubReleaseAssetURL

func ValidateOfficialGitHubReleaseAssetURL(release Release, asset ReleaseAsset) error

ValidateOfficialGitHubReleaseAssetURL 只接受固定仓库、选中 tag 和精确 asset 名组成的 GitHub HTTPS 下载端点。完整字符串相等也拒绝 query、fragment、userinfo、port 与任何 encoded 或歧义 path;真正下载时仍交由 HTTP client 跟随 GitHub 的合法重定向。

Types

type GitHubReleaseClient

type GitHubReleaseClient struct {
	// contains filtered or unexported fields
}

GitHubReleaseClient 通过 GitHub Releases API 查询候选版本。

func NewGitHubReleaseClient

func NewGitHubReleaseClient(options ReleaseClientOptions) (*GitHubReleaseClient, error)

NewGitHubReleaseClient 建立唯一使用 GitHub Releases API 的更新查询客户端。

func (*GitHubReleaseClient) Check

Check 从 GitHub Releases API 选择符合渠道的最高 SemVer Release。

type Release

type Release struct {
	TagName    string
	Version    string
	Prerelease bool
	Assets     []ReleaseAsset
}

Release 是可用于更新的 GitHub Release 的最小公开描述。

type ReleaseAsset

type ReleaseAsset struct {
	Name        string `json:"name"`
	DownloadURL string `json:"browser_download_url"`
}

ReleaseAsset 是 GitHub Release 附带的一个可下载资产。 仅使用 Releases API 返回的 browser_download_url,避免根据 tag 猜测下载地址。

type ReleaseCache

type ReleaseCache interface {
	Read(ctx context.Context) ([]byte, bool, error)
	Write(ctx context.Context, data []byte) error
}

ReleaseCache 是 GitHub Releases 缓存的后端存储端口。读取时第二个返回值 报告条目是否已存在;写入必须原子完成并保持私密权限。

type ReleaseCheckOptions

type ReleaseCheckOptions struct {
	IncludePrerelease bool
	Automatic         bool
}

ReleaseCheckOptions 表示一次 Releases 查询的渠道与触发方式。

type ReleaseCheckResult

type ReleaseCheckResult struct {
	Release   *Release
	Throttled bool
}

ReleaseCheckResult 是一次查询得到的候选 Release。

type ReleaseChecker

type ReleaseChecker interface {
	Check(context.Context, ReleaseCheckOptions) (ReleaseCheckResult, error)
}

ReleaseChecker 查询某个更新渠道可用的 GitHub Release。

type ReleaseClientOptions

type ReleaseClientOptions struct {
	APIBaseURL                 string
	Repository                 string
	HTTPClient                 *http.Client
	CacheDir                   string
	Cache                      ReleaseCache
	Now                        func() time.Time
	EnablePublicReleaseSources bool
}

ReleaseClientOptions 配置 GitHub Releases 客户端。 APIBaseURL、Repository、HTTPClient、CacheDir 和 Now 允许调用方为受控环境注入依赖; Cache 是 release cache 的存储端口,生产默认文件实现由安装器提供。

type SemanticVersion

type SemanticVersion struct {
	// contains filtered or unexported fields
}

SemanticVersion 是经过校验的 canonical SemVer 版本;数字标识符不做数值上限。

func ParseSemanticVersion

func ParseSemanticVersion(tag string) (SemanticVersion, error)

ParseSemanticVersion 解析并校验带 v 前缀的 SemVer tag。

func (SemanticVersion) Compare

func (v SemanticVersion) Compare(other SemanticVersion) int

Compare 按 SemVer 优先级比较两个版本。

func (SemanticVersion) IsPrerelease

func (v SemanticVersion) IsPrerelease() bool

IsPrerelease 报告该版本是否带 prerelease 标识符。

func (SemanticVersion) String

func (v SemanticVersion) String() string

String 输出不含 v 前缀的 canonical 版本文本。

Jump to

Keyboard shortcuts

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