artifact

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 21 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. The accepted set must stay in sync with util.ExtractArchive: accepting a format we cannot extract turns "no artifacts found" into a cryptic decode error.

func PackageBinaries added in v0.8.0

func PackageBinaries(packages, binaries []string, modDir string) []string

PackageBinaries pairs each package with the binary name it produces: binaries[i] when configured, and otherwise the package's base name (the module directory's own name for ".", falling back to "app"). Both the cross-compiler and the generated formula's source-build block go through here, so they can never disagree on which binary comes from which package.

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 ShortCommit added in v0.8.2

func ShortCommit(commit string) string

ShortCommit abbreviates a commit SHA to the conventional 7 characters (the {{.ShortCommit}} ldflags field; goreleaser's .ShortCommit equivalent).

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}}, {{.ShortCommit}},
	// {{.Date}}, {{.Tag}})
	Ldflags string

	// Build tags, passed as a single -tags argument
	Tags []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. There is no default here: the
	// caller decides (config.BuildConfig.TrimpathEnabled defaults it to 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. Archive artifacts are copied as a single file; binary artifacts (artifacts.json mode) are staged as a DIRECTORY of correctly-named binaries, and the directory path is returned.

func (*LocalSource) List

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

List returns all available artifacts from the local directory. When goreleaser's dist/artifacts.json is present, the raw built binaries it describes are preferred over archives: no extraction round-trip, and the bottled bytes are exactly the (attestable) build outputs. Archives remain the fallback for hand-rolled dist directories. Note raw binaries are not covered by goreleaser's checksum manifest (archives only) — within-job filesystem trust applies.

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