Documentation
¶
Overview ¶
Package github provides shared GitHub client utilities for release tools.
Index ¶
- Constants
- func IsBot(username string) bool
- type AppIdentity
- type Client
- func (c *Client) API() *github.Client
- func (c *Client) BranchExists(ctx context.Context, branch string) (bool, error)
- func (c *Client) CreateBranch(ctx context.Context, p CreateBranchParams) error
- func (c *Client) CreateIssueComment(ctx context.Context, issueNumber int, body string) error
- func (c *Client) CreateTag(ctx context.Context, p CreateTagParams) error
- func (c *Client) EnsureLabel(ctx context.Context, p CreateLabelParams) (bool, error)
- func (c *Client) FindCherryPickedCommit(ctx context.Context, p FindCherryPickedCommitParams) (*github.RepositoryCommit, error)
- func (c *Client) GetAppIdentity(ctx context.Context) (AppIdentity, error)
- func (c *Client) GetCommit(ctx context.Context, sha string) (*github.RepositoryCommit, error)
- func (c *Client) GetPR(ctx context.Context, number int) (*github.PullRequest, error)
- func (c *Client) GetRefSHA(ctx context.Context, ref string) (string, error)
- func (c *Client) GetReleaseByTag(ctx context.Context, tag string) (*github.RepositoryRelease, error)
- func (c *Client) GraphQL(ctx context.Context, query string, variables map[string]any, result any) error
- func (c *Client) Owner() string
- func (c *Client) Repo() string
- func (c *Client) UpdateReleaseBody(ctx context.Context, releaseID int64, body string) error
- type ClientConfig
- type CreateBranchParams
- type CreateLabelParams
- type CreateTagParams
- type FindCherryPickedCommitParams
Constants ¶
const BackportLabelColor = "63a504"
BackportLabelColor is the hex color for backport labels (without '#' prefix).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppIdentity ¶
type AppIdentity struct {
Name string // e.g., "my-app[bot]"
Email string // e.g., "12345+my-app[bot]@users.noreply.github.com"
}
AppIdentity represents a GitHub App's git identity for commits.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API client with repository context.
func NewClient ¶
func NewClient(ctx context.Context, cfg ClientConfig) *Client
NewClient creates a new Client with the given configuration.
func NewClientFromEnv ¶
NewClientFromEnv creates a new Client from environment variables. Reads GITHUB_TOKEN and GITHUB_REPOSITORY (format: owner/repo).
func (*Client) BranchExists ¶
BranchExists checks if a branch exists in the repository.
func (*Client) CreateBranch ¶
func (c *Client) CreateBranch(ctx context.Context, p CreateBranchParams) error
CreateBranch creates a new branch from the given SHA.
func (*Client) CreateIssueComment ¶
CreateIssueComment adds a comment to an issue or pull request.
func (*Client) CreateTag ¶
func (c *Client) CreateTag(ctx context.Context, p CreateTagParams) error
CreateTag creates an annotated tag ref for the given SHA.
func (*Client) EnsureLabel ¶
EnsureLabel creates a label if it doesn't already exist. Returns true if the label was created, false if it already existed.
func (*Client) FindCherryPickedCommit ¶
func (c *Client) FindCherryPickedCommit(ctx context.Context, p FindCherryPickedCommitParams) (*github.RepositoryCommit, error)
FindCherryPickedCommit searches the commit history of a branch for a commit message containing the original commit SHA. It returns nil when no matching commit is found.
func (*Client) GetAppIdentity ¶
func (c *Client) GetAppIdentity(ctx context.Context) (AppIdentity, error)
GetAppIdentity returns the GitHub App's identity for use in git commits. It checks for APP_SLUG environment variable and fetches the bot user ID from the API. The bot user ID is required for GitHub to properly attribute commits.
func (*Client) GetReleaseByTag ¶
func (c *Client) GetReleaseByTag(ctx context.Context, tag string) (*github.RepositoryRelease, error)
GetReleaseByTag fetches a release by its tag name.
type ClientConfig ¶
ClientConfig holds configuration for creating a new Client.
type CreateBranchParams ¶
CreateBranchParams holds parameters for CreateBranch.
type CreateLabelParams ¶
type CreateLabelParams struct {
Name string // Label name
Color string // Hex color without '#' prefix (e.g., "ff0000")
Description string // Optional description
}
CreateLabelParams holds parameters for CreateLabel.
type CreateTagParams ¶
CreateTagParams holds parameters for CreateTag.
type FindCherryPickedCommitParams ¶
FindCherryPickedCommitParams holds parameters for FindCherryPickedCommit.