Documentation
¶
Overview ¶
Package github provides a client for interacting with GitHub Releases API.
Package github provides testing helpers for GitHub client.
Index ¶
- Variables
- type Client
- func (c *Client) CreateRelease(tag, name, body string, draft bool) (*github.RepositoryRelease, error)
- func (c *Client) FindReleaseAssetDownloadURL(releaseID int64, filename string) (string, error)
- func (c *Client) GetAssetDownloadURL(asset *github.ReleaseAsset) string
- func (c *Client) GetRelease(tag string) (*github.RepositoryRelease, error)
- func (c *Client) GetReleaseURL(release *github.RepositoryRelease) string
- func (c *Client) UploadAsset(releaseID int64, filePath string) (*github.ReleaseAsset, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyToken = errors.New("github token cannot be empty") ErrInvalidRepo = errors.New("repository must be in format 'owner/repo'") ErrNilRelease = errors.New("github release cannot be nil") ErrReleaseNotFound = errors.New("release not found") )
Sentinel errors for GitHub operations.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API client for release operations.
func NewClient ¶
NewClient creates a new GitHub API client for the specified repository. Token should be a personal access token or GitHub Actions token with repo permissions. Repository must be in the format "owner/repo".
func NewTestClient ¶
NewTestClient creates a GitHub client for testing with a custom HTTP client and base URL. This allows tests to use httptest.Server for mocking GitHub API responses. The baseURL should be the URL of your httptest.NewServer().
func (*Client) CreateRelease ¶
func (c *Client) CreateRelease(tag, name, body string, draft bool) (*github.RepositoryRelease, error)
CreateRelease creates a new GitHub release. Returns the created release metadata including the HTML URL and upload URL.
func (*Client) FindReleaseAssetDownloadURL ¶
FindReleaseAssetDownloadURL looks up an asset by filename for a given release. Returns empty string when the asset does not exist.
func (*Client) GetAssetDownloadURL ¶
func (c *Client) GetAssetDownloadURL(asset *github.ReleaseAsset) string
GetAssetDownloadURL returns the direct download URL for an asset. This URL can be used to download the asset publicly.
func (*Client) GetRelease ¶
func (c *Client) GetRelease(tag string) (*github.RepositoryRelease, error)
GetRelease retrieves an existing release by tag name. Returns ErrReleaseNotFound if the release doesn't exist.
func (*Client) GetReleaseURL ¶
func (c *Client) GetReleaseURL(release *github.RepositoryRelease) string
GetReleaseURL returns the HTML URL for a release.
func (*Client) UploadAsset ¶
UploadAsset uploads a file as a release asset. The file will be read from the provided path and uploaded to the specified release. Returns the created asset with its download URL.