github

package
v0.0.0-...-2b1ef52 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package github provides a client for interacting with GitHub Releases API.

Package github provides testing helpers for GitHub client.

Index

Constants

This section is empty.

Variables

View Source
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

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

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

func NewTestClient(httpClient *http.Client, baseURL, repository string) (*Client, error)

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

func (c *Client) FindReleaseAssetDownloadURL(releaseID int64, filename string) (string, error)

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

func (c *Client) UploadAsset(releaseID int64, filePath string) (*github.ReleaseAsset, error)

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.

Jump to

Keyboard shortcuts

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