artifact

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsArchive

func IsArchive(filename string) bool

IsArchive checks if a filename appears to be an archive

func ParseArtifactName

func ParseArtifactName(filename string) (os, arch string, ok bool)

ParseArtifactName extracts OS and Arch from a GoReleaser artifact filename Expected formats:

  • {name}_{version}_{os}_{arch}.tar.gz
  • {name}_{version}_{os}_{arch}.zip
  • Handles various archive extensions

func ParseChecksumsFile

func ParseChecksumsFile(content string) map[string]string

ParseChecksumsFile parses a checksums.txt file (SHA256SUMS format) Format: <checksum> <filename>

func ValidateChecksum

func ValidateChecksum(actual, expected string) error

ValidateChecksum verifies that a file's checksum matches the expected value

Types

type Artifact

type Artifact struct {
	Name     string // e.g., "myapp_1.0.0_darwin_arm64.tar.gz"
	Path     string // local path to the file
	OS       string // "darwin", "linux"
	Arch     string // "amd64", "arm64"
	Checksum string // SHA256
}

Artifact represents a GoReleaser release artifact

func FilterArtifacts

func FilterArtifacts(artifacts []Artifact, os, arch string) []Artifact

FilterArtifacts filters artifacts by OS and/or Arch

type BuildTarget

type BuildTarget struct {
	OS   string
	Arch string
}

BuildTarget represents a single build target (OS/Arch combination)

func AllBuildTargets

func AllBuildTargets() []BuildTarget

AllBuildTargets returns all Homebrew-supported build targets

type GitHubSource

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

GitHubSource fetches artifacts from GitHub releases

func NewGitHubSource

func NewGitHubSource(cfg GitHubSourceConfig) (*GitHubSource, error)

NewGitHubSource creates a new GitHub artifact source

func (*GitHubSource) Close

func (s *GitHubSource) Close() error

Close releases any resources and cleans up temp directory

func (*GitHubSource) Fetch

func (s *GitHubSource) Fetch(ctx context.Context, artifact Artifact, targetDir string) (string, error)

Fetch downloads a GitHub release asset to the target directory

func (*GitHubSource) List

func (s *GitHubSource) List(ctx context.Context) ([]Artifact, error)

List returns all available artifacts from the GitHub release

type GitHubSourceConfig

type GitHubSourceConfig struct {
	Owner string // GitHub repository owner
	Repo  string // GitHub repository name
	Tag   string // Release tag (e.g., "v1.0.0")
	Token string // GitHub token (optional, for private repos or rate limiting)
}

GitHubSourceConfig configures a GitHub artifact source

type GoSource

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

GoSource builds Go binaries and creates artifacts for bottle building

func NewGoSource

func NewGoSource(cfg GoSourceConfig) (*GoSource, error)

NewGoSource creates a new Go source for building binaries

func (*GoSource) BinaryNames

func (s *GoSource) BinaryNames() []string

BinaryNames returns the names of binaries that will be produced

func (*GoSource) Close

func (s *GoSource) Close() error

Close releases any resources

func (*GoSource) Fetch

func (s *GoSource) Fetch(ctx context.Context, artifact Artifact, targetDir string) (string, error)

Fetch copies an artifact to the target directory

func (*GoSource) List

func (s *GoSource) List(ctx context.Context) ([]Artifact, error)

List returns all available artifacts (builds them if not already built)

type GoSourceConfig

type GoSourceConfig struct {
	// Packages to build (e.g., ["./cmd/myapp"])
	Packages []string

	// Ldflags template (supports {{.Version}}, {{.Commit}}, {{.Date}}, {{.Tag}})
	Ldflags string

	// Extra environment variables for go build, as KEY=value strings
	Env []string

	// Enable CGO (default: false for portable static binaries)
	CGOEnabled bool

	// Use -trimpath for reproducible builds (default: true)
	Trimpath bool

	// Extra go build flags
	Flags []string

	// Path to go.mod directory (default: ".")
	ModDir string

	// Number of parallel builds (default: GOMAXPROCS)
	Parallel int

	// Version string for ldflags template
	Version string

	// Git commit SHA for ldflags template
	Commit string

	// Git tag for ldflags template
	Tag string

	// Build date for ldflags template (default: now or SOURCE_DATE_EPOCH)
	Date time.Time

	// Binary names to use (defaults to package base name)
	Binaries []string

	// Targets restricts the GOOS/GOARCH combinations to build
	// (default: all Homebrew-supported targets)
	Targets []BuildTarget
}

GoSourceConfig holds configuration for building Go binaries

type LocalSource

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

LocalSource reads artifacts from a local directory (typically dist/)

func NewLocalSource

func NewLocalSource(distPath string) (*LocalSource, error)

NewLocalSource creates a new local artifact source

func (*LocalSource) Close

func (s *LocalSource) Close() error

Close releases any resources (no-op for local source)

func (*LocalSource) Fetch

func (s *LocalSource) Fetch(ctx context.Context, artifact Artifact, targetDir string) (string, error)

Fetch copies an artifact to the target directory For local source, this is just a file copy

func (*LocalSource) List

func (s *LocalSource) List(ctx context.Context) ([]Artifact, error)

List returns all available artifacts from the local directory

type Source

type Source interface {
	// List returns all available artifacts
	List(ctx context.Context) ([]Artifact, error)
	// Fetch downloads/copies an artifact to the target directory
	Fetch(ctx context.Context, artifact Artifact, targetDir string) (string, error)
	// Close releases any resources
	Close() error
}

Source is the interface for artifact sources

Jump to

Keyboard shortcuts

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