rel

package
v0.6.25 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlatformLinux     = "linux"
	PlatformDarwin    = "darwin"
	PlatformWindows   = "windows"
	PlatformFreeBSD   = "freebsd"
	PlatformOpenBSD   = "openbsd"
	PlatformNetBSD    = "netbsd"
	PlatformDragonfly = "dragonfly"
	PlatformSolaris   = "solaris"
)

Standard platforms

View Source
const (
	ArchAMD64    = "amd64"
	Arch386      = "386"
	ArchARM64    = "arm64"
	ArchARM      = "arm"
	ArchPPC64    = "ppc64"
	ArchPPC64LE  = "ppc64le"
	ArchMIPS     = "mips"
	ArchMIPSLE   = "mipsle"
	ArchMIPS64   = "mips64"
	ArchMIPS64LE = "mips64le"
	ArchS390X    = "s390x"
)

Standard architectures

Variables

This section is empty.

Functions

func CheckValidVersion

func CheckValidVersion(str string) error

CheckValidVersion strictly validates if the input string matches the "x.y.z" version format Rules: 1. Exact 3 segments separated by single dots (no extra dots, no missing segments) 2. Each segment is a non-negative integer (no letters/symbols) 3. No leading zeros in segments (except single zero like "0.0.0") 4. No empty segments (e.g., "1..3" is invalid)

func CompareVersion

func CompareVersion(r1, r2 Version) int

func DownloadGitHubRelease

func DownloadGitHubRelease(group, repo, version string) (string, error)

DownloadGitHubRelease fetches GitHub Release JSON data by group/repo/version Parameters:

group - GitHub organization/username (e.g. "kumose")
repo  - Repository name (e.g. "kmdo")
version - Release tag (e.g. "v0.6.24")

Returns:

JSON string of the release on success, empty string on failure

func DownloadKmupRelease

func DownloadKmupRelease(host, group, repo, version string) (string, error)

DownloadKmupRelease strictly follows your prototype: Params: group(repo owner), repo(repo name), version(tag) Returns: Raw JSON string (empty on failure)

func GithubReleaseUrl

func GithubReleaseUrl(group, repo, version string) string

func KmupReleaseUrl

func KmupReleaseUrl(host, group, repo, version string) string

func LocalArch

func LocalArch() string

LocalArch returns the normalized architecture of the current system. It panics if the architecture is unknown.

func LocalPlatform

func LocalPlatform() string

LocalPlatform returns the normalized platform of the current system. It panics if the platform is unknown.

Types

type AssetFile

type AssetFile struct {
	Name     string
	Version  string
	Arch     string
	Platform string
	Ext      string
	Release  string
}

func ParseFromFilename

func ParseFromFilename(filename string) (AssetFile, error)

func ParseFromSimpleTemplate

func ParseFromSimpleTemplate(filename, tmpl string) (AssetFile, error)

ParseFromSimpleTemplate parses filename using simple sprintf-style template

func (*AssetFile) NormalizePlatformAndArch

func (a *AssetFile) NormalizePlatformAndArch() error

type GitHubRelease

type GitHubRelease struct {
	URL             string               `json:"url"`
	AssetsURL       string               `json:"assets_url"`
	UploadURL       string               `json:"upload_url"`
	HTMLURL         string               `json:"html_url"`
	ID              int64                `json:"id"`
	Author          GithubUser           `json:"author"`
	NodeID          string               `json:"node_id"`
	TagName         string               `json:"tag_name"`
	TargetCommitish string               `json:"target_commitish"`
	Name            string               `json:"name"`
	Draft           bool                 `json:"draft"`
	Immutable       bool                 `json:"immutable"`
	Prerelease      bool                 `json:"prerelease"`
	CreatedAt       string               `json:"created_at"`
	UpdatedAt       string               `json:"updated_at"`
	PublishedAt     string               `json:"published_at"`
	Assets          []GithubReleaseAsset `json:"assets"`
	TarballURL      string               `json:"tarball_url"`
	ZipballURL      string               `json:"zipball_url"`
	Body            string               `json:"body"`
}

GitHubRelease represents the entire GitHub Release response structure

func ParseGitHubRelease

func ParseGitHubRelease(data string) (*GitHubRelease, error)

type GithubReleaseAsset

type GithubReleaseAsset struct {
	URL                string     `json:"url"`
	ID                 int64      `json:"id"`
	NodeID             string     `json:"node_id"`
	Name               string     `json:"name"`
	Label              string     `json:"label"`
	Uploader           GithubUser `json:"uploader"`
	ContentType        string     `json:"content_type"`
	State              string     `json:"state"`
	Size               int64      `json:"size"`
	Digest             string     `json:"digest"`
	DownloadCount      int64      `json:"download_count"`
	CreatedAt          string     `json:"created_at"`
	UpdatedAt          string     `json:"updated_at"`
	BrowserDownloadURL string     `json:"browser_download_url"`
}

ReleaseAsset represents a single asset file in the GitHub Release

type GithubUser

type GithubUser struct {
	Login             string `json:"login"`
	ID                int64  `json:"id"`
	NodeID            string `json:"node_id"`
	AvatarURL         string `json:"avatar_url"`
	GravatarID        string `json:"gravatar_id"`
	URL               string `json:"url"`
	HTMLURL           string `json:"html_url"`
	FollowersURL      string `json:"followers_url"`
	FollowingURL      string `json:"following_url"`
	GistsURL          string `json:"gists_url"`
	StarredURL        string `json:"starred_url"`
	SubscriptionsURL  string `json:"subscriptions_url"`
	OrganizationsURL  string `json:"organizations_url"`
	ReposURL          string `json:"repos_url"`
	EventsURL         string `json:"events_url"`
	ReceivedEventsURL string `json:"received_events_url"`
	Type              string `json:"type"`
	UserViewType      string `json:"user_view_type"`
	SiteAdmin         bool   `json:"site_admin"`
}

User represents GitHub user information (author/uploader)

type KmupRelease

type KmupRelease struct {
	ID              int                `json:"id"`
	TagName         string             `json:"tag_name"`
	TargetCommitish string             `json:"target_commitish"`
	Name            string             `json:"name"`
	Body            string             `json:"body"`
	URL             string             `json:"url"`
	HTMLURL         string             `json:"html_url"`
	TarballURL      string             `json:"tarball_url"`
	ZipballURL      string             `json:"zipball_url"`
	UploadURL       string             `json:"upload_url"`
	Draft           bool               `json:"draft"`
	Prerelease      bool               `json:"prerelease"`
	CreatedAt       string             `json:"created_at"`
	PublishedAt     string             `json:"published_at"`
	Author          KmupReleaseAuthor  `json:"author"`
	Assets          []KmupReleaseAsset `json:"assets"`
}

CustomRelease represents the full structure of your local API release JSON

func ParseKmupReleaseJSON

func ParseKmupReleaseJSON(jsonStr string) (*KmupRelease, error)

ParseKmupReleaseJSON parses raw JSON string into KmupRelease struct Returns parsed struct and error (nil if success)

type KmupReleaseAsset

type KmupReleaseAsset struct {
	ID                 int    `json:"id"`
	Name               string `json:"name"`
	Size               int64  `json:"size"`
	DownloadCount      int    `json:"download_count"`
	CreatedAt          string `json:"created_at"`
	UUID               string `json:"uuid"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

ReleaseAsset represents the assets array items in the custom release JSON

type KmupReleaseAuthor

type KmupReleaseAuthor struct {
	ID                int    `json:"id"`
	Login             string `json:"login"`
	LoginName         string `json:"login_name"`
	SourceID          int    `json:"source_id"`
	FullName          string `json:"full_name"`
	Email             string `json:"email"`
	AvatarURL         string `json:"avatar_url"`
	HTMLURL           string `json:"html_url"`
	Language          string `json:"language"`
	IsAdmin           bool   `json:"is_admin"`
	LastLogin         string `json:"last_login"`
	Created           string `json:"created"`
	Restricted        bool   `json:"restricted"`
	Active            bool   `json:"active"`
	ProhibitLogin     bool   `json:"prohibit_login"`
	Location          string `json:"location"`
	Website           string `json:"website"`
	Description       string `json:"description"`
	Visibility        string `json:"visibility"`
	FollowersCount    int    `json:"followers_count"`
	FollowingCount    int    `json:"following_count"`
	StarredReposCount int    `json:"starred_repos_count"`
	Username          string `json:"username"`
}

ReleaseAuthor represents the author object in the custom release JSON

type MirrorAsset

type MirrorAsset struct {
	Url      string `json:"url"`      // Download URL of the mirrored asset
	Digest   string `json:"digest"`   // SHA256 checksum of the asset
	Name     string `json:"name"`     // Filename of the asset
	Platform string `json:"platform"` // OS platform (e.g., linux, darwin, windows)
	Arch     string `json:"arch"`     // CPU architecture (e.g., amd64, arm64, x86_64)
	Size     int64  `json:"size"`     // File size in bytes
}

MirrorAsset represents a single mirrored asset with platform/arch metadata (JSON serializable)

type MirrorManifest

type MirrorManifest struct {
	Name    string        `json:"name"`    // Name of the mirrored package/project
	Version string        `json:"version"` // Version of the manifest/package
	Create  string        `json:"create"`  // Creation timestamp (RFC3339 format recommended)
	Url     string        `json:"url"`     // Base URL of the original release
	Assets  []MirrorAsset `json:"assets"`  // List of mirrored assets (renamed to plural for JSON convention)
}

MirrorManifest represents a manifest for mirrored assets (JSON serializable)

func BuildFromGithub

func BuildFromGithub(name string, ver string, tmpl string, r *GitHubRelease) (*MirrorManifest, error)

func BuildFromKmup

func BuildFromKmup(name string, ver string, tmpl string, r *KmupRelease) (*MirrorManifest, error)

func (*MirrorManifest) Add

func (m *MirrorManifest) Add(asset MirrorAsset) error

Add appends a MirrorAsset to the manifest (prevents duplicate asset names)

func (*MirrorManifest) Load

func (m *MirrorManifest) Load(path string) error

Load reads a MirrorManifest from a JSON file at the specified path Overwrites the current manifest data with the loaded content

func (*MirrorManifest) Remove

func (m *MirrorManifest) Remove(name string) error

Remove deletes an asset from the manifest by name (case-sensitive) Returns error if asset with the given name is not found

func (*MirrorManifest) Save

func (m *MirrorManifest) Save(path string) error

Save writes the MirrorManifest to a JSON file at the specified path Creates parent directories if they don't exist, overwrites existing file

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

func ParseVersion

func ParseVersion(str string) (Version, error)

Jump to

Keyboard shortcuts

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