github

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package github provides a thin REST client for the GitHub API, scoped to the endpoints needed to discover the latest versions of GitHub Actions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError captures any other non-success response.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client talks to the GitHub REST API.

func NewClient

func NewClient(opts ...Option) *Client

NewClient builds a Client. If no token is supplied via WithToken, it falls back to the GITHUB_TOKEN environment variable, which raises the rate limit from 60 to 5000 requests per hour.

func (*Client) LatestRelease

func (c *Client) LatestRelease(ctx context.Context, owner, repo string) (*Release, error)

LatestRelease returns the latest published, non-draft release.

func (*Client) ListReleases

func (c *Client) ListReleases(ctx context.Context, owner, repo string, limit int) ([]Release, error)

ListReleases returns up to limit releases, newest first. A limit <= 0 means "use the GitHub default page size".

type NotFoundError

type NotFoundError struct {
	Resource string
}

NotFoundError is returned when the GitHub API responds with 404.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL overrides the API base URL (used in tests).

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient overrides the underlying HTTP client.

func WithToken

func WithToken(token string) Option

WithToken sets the bearer token explicitly.

type RateLimitError

type RateLimitError struct {
	Authenticated bool
}

RateLimitError is returned when the GitHub API rate limit is exhausted.

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type Release

type Release struct {
	TagName     string    `json:"tag_name"`
	PublishedAt time.Time `json:"published_at"`
	HTMLURL     string    `json:"html_url"`
	Prerelease  bool      `json:"prerelease"`
	Draft       bool      `json:"draft"`
}

Release mirrors the fields we consume from a GitHub release object.

Jump to

Keyboard shortcuts

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