github

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package github provides GitHub API interactions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized  = errors.New("unauthorized: GITHUB_TOKEN is missing or expired")
	ErrForbidden     = errors.New("forbidden: GITHUB_TOKEN lacks required permissions")
	ErrNotFound      = errors.New("not found: resource does not exist")
	ErrUnprocessable = errors.New("unprocessable: GitHub API rejected request")
	ErrRateLimited   = errors.New("rate limited: GitHub API rate limit exceeded")
	ErrServerError   = errors.New("server error: GitHub API returned 5xx")
)

Typed errors for GitHub API responses.

Functions

This section is empty.

Types

type Client

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

Client wraps the go-github client.

func NewClient

func NewClient(token, baseURL string) (*Client, error)

NewClient constructs a GitHub API client. baseURL is the value of GITHUB_API_URL (may be empty or without trailing slash). For the default GitHub.com API URL, the standard client is returned. For any other non-empty URL (GHES), WithEnterpriseURLs is used. A trailing slash is added automatically — go-github v60 requires it.

func (*Client) CreateRelease

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

CreateRelease creates a new GitHub release. On HTTP 422 with errors[].code == "already_exists", calls GetReleaseByTag and returns that result. Returns (Release, nil) on success, typed errors on other failures.

func (*Client) FindPRComment

func (c *Client) FindPRComment(ctx context.Context, owner, repo string, prNumber int, marker string) (bool, error)

FindPRComment searches for an existing comment on a PR by marker string. marker: substring to search for in comment body (e.g., "<!-- semrel-notify:v1.4.0 -->") Returns (true, nil) if found, (false, nil) if not found, (false, error) on API failure.

func (*Client) GetReleaseByTag

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

GetReleaseByTag retrieves a release by tag name. Returns (Release, nil) on 200, typed errors on other status codes.

func (*Client) ListPRsForCommit

func (c *Client) ListPRsForCommit(ctx context.Context, owner, repo, sha string) ([]PR, error)

ListPRsForCommit retrieves all PRs associated with a commit SHA. Calls GET /repos/{owner}/{repo}/commits/{sha}/pulls Returns ([]PR, nil) on success, typed errors on failure.

func (*Client) PostPRComment

func (c *Client) PostPRComment(ctx context.Context, owner, repo string, prNumber int, body string) error

PostPRComment posts a comment on a pull request. Returns nil on success, typed errors on failure.

func (*Client) SearchPRsForCommit

func (c *Client) SearchPRsForCommit(ctx context.Context, query string) ([]PR, error)

SearchPRsForCommit searches for PRs using a query string. Calls GET /search/issues?q=<query> Returns ([]PR, nil) on success, typed errors on failure.

type CreateReleaseOptions

type CreateReleaseOptions struct {
	TagName string
	Name    string
	Body    string
}

CreateReleaseOptions for CreateRelease.

type PR

type PR struct {
	Number int
	URL    string
	Title  string
}

PR represents a GitHub pull request.

type Release

type Release struct {
	ID      int64
	TagName string
	HTMLURL string
	Body    string
}

Release represents a GitHub release.

Jump to

Keyboard shortcuts

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