githubreleasedownloader

package module
v0.0.0-...-520dc41 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 18 Imported by: 0

README

Tests on Linux, MacOS and Windows Go Report Card GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	// Name is the name of the asset.
	Name string `json:"name"`
	// URL is the URL to download the asset.
	URL string `json:"url"`
	// Sha256 is the sha256 checksum of the asset.
	Sha256 string `json:"sha256"`
	// ContentType is the content type of the asset.
	ContentType string `json:"content_type"`
	// Size is the size of the asset in bytes.
	Size int `json:"size"`
}

Asset represents a GitHub release asset.

type Assets

type Assets []Asset

Assets is a slice of Asset.

func (Assets) Filter

func (a Assets) Filter(f func(Asset) bool) Assets

Filter returns a new Assets slice containing only the assets for which the given function returns true.

type Client

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

func New

func New() (*Client, error)

func (*Client) GetRelease

func (c *Client) GetRelease(owner, repo, tag string) (Release, error)

GetRelease returns the release for the given owner, repo and tag. Note that this method will download the assets to calculate their sha256 checksums, so it can be slow for large assets etc.

type DownloadAssetOptions

type DownloadAssetOptions struct {
	TargetBaseDir         string
	ExtractToSubDirectory bool
	ExtractFilter         func(filename string, isDir bool) bool
}

type DownloadAssetsResult

type DownloadAssetsResult struct {
	TargetDir string
}

func DownloadAndExtractAsset

func DownloadAndExtractAsset(asset Asset, opts DownloadAssetOptions) (DownloadAssetsResult, error)

DownloadAndExtractAsset downloads and extracts the given asset to the given directory. If the SHA256 checksum of the downloaded file does not match the one stored in the asset, an error is returned.

type Release

type Release struct {
	TagName         string    `json:"tag_name"`
	TargetCommitish string    `json:"target_commitish"`
	Name            string    `json:"name"`
	Draft           bool      `json:"draft"`
	Prerelease      bool      `json:"prerelease"`
	CreatedAt       time.Time `json:"created_at"`
	PublishedAt     time.Time `json:"published_at"`
	Assets          Assets    `json:"assets"`
}

Release represents a GitHub release.

Jump to

Keyboard shortcuts

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