Documentation
¶
Overview ¶
Package github provides functionality to interact with GitHub repositories, releases, and assets via the GitHub API. It includes utilities for filtering and retrieving release information, assets, and repository metadata.
The main types and functions in this package include:
- Asset: Represents a GitHub release asset with name, URL, and content type.
- Assets: A collection of Asset objects with filtering methods.
- Release: Represents a GitHub release containing a tag, name, and assets.
- Repository: Represents a GitHub repository, with methods for retrieving releases, assets, and repository details.
- NewClient: Creates a new GitHub API client.
- NewRepository: Creates a new Repository instance for accessing repository data.
This package uses the Google GitHub client (github.com/google/go-github/v64) for making API calls and provides additional utilities to handle GitHub data.
Index ¶
- Variables
- func NewClient(token string) *github.Client
- type Asset
- type Assets
- type Release
- type Repository
- func (r *Repository) GetRelease(ctx context.Context, tag string) (*Release, error)
- func (r *Repository) GetReleaseFromWeb(ctx context.Context, tag string) (*Release, error)
- func (r *Repository) GetReleasesByWildcard(ctx context.Context, pattern string, perPage int) (*Release, error)
- func (r *Repository) LatestIncludingPreRelease(ctx context.Context, perPage int) (*Release, error)
- func (r *Repository) LatestRelease(ctx context.Context) (*Release, error)
- func (r *Repository) LatestVersionFromWebHTML(ctx context.Context) (string, error)
- func (r *Repository) LatestVersionFromWebJSON(ctx context.Context) (string, error)
- type WebReleaseInfo
Constants ¶
This section is empty.
Variables ¶
var ErrRelease = errors.New("release")
ErrRelease is returned when a release issue is encountered.
Functions ¶
Types ¶
type Asset ¶
type Asset struct { // Name is the name of the asset. Name string `json:"name"` // URL is the browser download URL for the asset. URL string `json:"browser_download_url"` //nolint:tagliatelle // This is how GitHub returns the URL for the asset. // Type is the content type of the asset. Type string `json:"content_type"` //nolint:tagliatelle // This is how GitHub returns the content type for the asset. }
Asset represents a GitHub release asset with its name, download URL, and content type.
func (Asset) HasExtension ¶
HasExtension checks if the asset has the given file extension.
type Assets ¶
type Assets []Asset
Assets represents a collection of GitHub release assets.
func (Assets) FilterByName ¶
FilterByName returns the assets that match the given name. It compares asset names in a case-insensitive manner.
type Release ¶
type Release struct { Name string `json:"name"` Tag string `json:"tag_name"` Body string `json:"body"` Assets Assets `json:"assets"` }
Release represents a GitHub release, containing the release name, tag, and associated assets.
func (*Release) FromRepositoryRelease ¶
func (r *Release) FromRepositoryRelease(release *github.RepositoryRelease) error
FromRepositoryRelease converts a GitHub repository release to a Release object.
type Repository ¶
Repository represents a GitHub repository with its owner and name. It contains a GitHub client for making API calls.
func NewRepository ¶
func NewRepository(owner, repo string, client *github.Client) *Repository
NewRepository creates a new instance of Repository. It requires the repository owner, repository name, and a GitHub client.
func (*Repository) GetRelease ¶
GetRelease retrieves a specific release for the repository based on the provided tag.
func (*Repository) GetReleaseFromWeb ¶ added in v0.0.18
GetReleaseFromWeb retrieves a specific release for the repository based on the provided tag.
func (*Repository) GetReleasesByWildcard ¶ added in v0.1.1
func (r *Repository) GetReleasesByWildcard(ctx context.Context, pattern string, perPage int) (*Release, error)
GetReleasesByWildcard retrieves the latest release matching a wildcard pattern. It returns the highest version that matches the pattern.
func (*Repository) LatestIncludingPreRelease ¶ added in v0.0.18
LatestIncludingPreRelease retrieves the most recently published release for the repository, including pre-releases. This returns the newest release by published date, regardless of whether it's a regular release or pre-release.
func (*Repository) LatestRelease ¶
func (r *Repository) LatestRelease(ctx context.Context) (*Release, error)
LatestRelease retrieves the latest release for the repository.
func (*Repository) LatestVersionFromWebHTML ¶ added in v0.0.18
func (r *Repository) LatestVersionFromWebHTML(ctx context.Context) (string, error)
LatestVersionFromWebHTML retrieves the latest release for the repository using the GitHub website instead of the API, avoiding rate limits.
func (*Repository) LatestVersionFromWebJSON ¶ added in v0.0.18
func (r *Repository) LatestVersionFromWebJSON(ctx context.Context) (string, error)
LatestVersionFromWebJSON retrieves the latest release for the repository using the GitHub website instead of the API, avoiding rate limits.
type WebReleaseInfo ¶ added in v0.0.11
type WebReleaseInfo struct {
Tag string `json:"tag_name"`
}
WebReleaseInfo stores information about a release fetched from the GitHub web interface.