github

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GitHubAPI is the base URL for GitHub API
	GitHubAPI = "https://api.github.com"

	// ArchiveURLTemplate is the template for downloading release archives
	// Format: https://github.com/{owner}/{repo}/archive/refs/tags/{tag}.tar.gz
	ArchiveURLTemplate = "https://github.com/%s/%s/archive/refs/tags/v%s.tar.gz"

	// BranchArchiveURLTemplate is the template for downloading branch archives
	// Format: https://github.com/{owner}/{repo}/archive/refs/heads/{branch}.tar.gz
	BranchArchiveURLTemplate = "https://github.com/%s/%s/archive/refs/heads/%s.tar.gz"

	// LatestReleaseURLTemplate is the template for fetching latest release info
	LatestReleaseURLTemplate = "https://api.github.com/repos/%s/%s/releases/latest"

	// TagsURLTemplate is the template for fetching tags
	TagsURLTemplate = "https://api.github.com/repos/%s/%s/tags"

	// DefaultBranch is the fallback when no releases exist
	DefaultBranch = "main"

	// DevVersion is returned when using main branch
	DevVersion = "dev"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides GitHub API operations

func NewClient

func NewClient(owner, repo string) *Client

NewClient creates a new GitHub client

func (*Client) CheckForUpdates

func (c *Client) CheckForUpdates(currentVersion string) (*VersionInfo, error)

CheckForUpdates compares current version with latest

func (*Client) DownloadArchive

func (c *Client) DownloadArchive(version string) (io.ReadCloser, int64, error)

DownloadArchive downloads the archive for a specific version

func (*Client) DownloadBranchArchive

func (c *Client) DownloadBranchArchive(branch string) (io.ReadCloser, int64, error)

DownloadBranchArchive downloads the archive for a branch

func (*Client) DownloadFile

func (c *Client) DownloadFile(version, path string) ([]byte, error)

DownloadFile downloads a single file from the repository

func (*Client) GetArchiveURL

func (c *Client) GetArchiveURL(version string) string

GetArchiveURL returns the URL to download a specific version

func (*Client) GetBranchArchiveURL

func (c *Client) GetBranchArchiveURL(branch string) string

GetBranchArchiveURL returns the URL to download from a branch

func (*Client) GetLatestRelease

func (c *Client) GetLatestRelease() (*Release, error)

GetLatestRelease fetches the latest release information Returns nil without error if no releases exist (use GetLatestVersionOrBranch instead)

func (*Client) GetLatestVersionOrBranch

func (c *Client) GetLatestVersionOrBranch() (version string, isBranch bool, err error)

GetLatestVersionOrBranch returns the latest version, falling back to "dev" if no releases

func (*Client) GetTags

func (c *Client) GetTags() ([]Tag, error)

GetTags fetches available tags

type Release

type Release struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	Body        string    `json:"body"`
	PublishedAt time.Time `json:"published_at"`
	TarballURL  string    `json:"tarball_url"`
}

Release represents a GitHub release

type Tag

type Tag struct {
	Name string `json:"name"`
}

Tag represents a GitHub tag

type VersionInfo

type VersionInfo struct {
	Current      string
	Latest       string
	UpdateNeeded bool
	ReleaseNotes string
}

VersionInfo contains version comparison information

Jump to

Keyboard shortcuts

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