artifact

package
v1.25.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package artifact provides the core artifact storage for goreleaser.

Index

Constants

View Source
const (
	ExtraID         = "ID"
	ExtraBinary     = "Binary"
	ExtraExt        = "Ext"
	ExtraFormat     = "Format"
	ExtraWrappedIn  = "WrappedIn"
	ExtraBinaries   = "Binaries"
	ExtraRefresh    = "Refresh"
	ExtraReplaces   = "Replaces"
	ExtraDigest     = "Digest"
	ExtraSize       = "Size"
	ExtraChecksum   = "Checksum"
	ExtraChecksumOf = "ChecksumOf"
)

Variables

This section is empty.

Functions

func Extra added in v1.10.0

func Extra[T any](a Artifact, key string) (T, error)

Extra tries to get the extra field with the given name, returning either its value, the default value for its type, or an error.

If the extra value cannot be cast into the given type, it'll try to convert it to JSON and unmarshal it into the correct type after.

If that fails as well, it'll error.

func ExtraOr added in v1.10.0

func ExtraOr[T any](a Artifact, key string, or T) T

ExtraOr returns the Extra field with the given key or the or value specified if it is nil.

func OnlyReplacingUnibins added in v1.2.0

func OnlyReplacingUnibins(a *Artifact) bool

OnlyReplacingUnibins removes universal binaries that did not replace the single-arch ones.

This is useful specially on homebrew et al, where you'll want to use only either the single-arch or the universal binaries.

Types

type Artifact

type Artifact struct {
	Name    string `json:"name,omitempty"`
	Path    string `json:"path,omitempty"`
	Goos    string `json:"goos,omitempty"`
	Goarch  string `json:"goarch,omitempty"`
	Goarm   string `json:"goarm,omitempty"`
	Gomips  string `json:"gomips,omitempty"`
	Goamd64 string `json:"goamd64,omitempty"`
	Type    Type   `json:"internal_type,omitempty"`
	TypeS   string `json:"type,omitempty"`
	Extra   Extras `json:"extra,omitempty"`
}

Artifact represents an artifact and its relevant info.

func (Artifact) Checksum added in v0.84.0

func (a Artifact) Checksum(algorithm string) (string, error)

Checksum calculates the checksum of the artifact. nolint: gosec

func (Artifact) Format added in v0.183.0

func (a Artifact) Format() string

Format returns the artifact Format if it exists, empty otherwise.

func (Artifact) ID added in v0.183.0

func (a Artifact) ID() string

ID returns the artifact ID if it exists, empty otherwise.

func (Artifact) Refresh added in v1.2.0

func (a Artifact) Refresh() error

Refresh executes a Refresh extra function on artifacts, if it exists.

func (Artifact) String added in v1.2.0

func (a Artifact) String() string

type Artifacts

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

Artifacts is a list of artifacts.

func New

func New() *Artifacts

New return a new list of artifacts.

func (*Artifacts) Add

func (artifacts *Artifacts) Add(a *Artifact)

Add safely adds a new artifact to an artifact list.

func (*Artifacts) Filter

func (artifacts *Artifacts) Filter(filter Filter) *Artifacts

Filter filters the artifact list, returning a new instance. There are some pre-defined filters but anything of the Type Filter is accepted. You can compose filters by using the And and Or filters.

func (*Artifacts) GroupByID added in v1.4.0

func (artifacts *Artifacts) GroupByID() map[string][]*Artifact

GroupByID groups the artifacts by their ID.

func (*Artifacts) GroupByPlatform

func (artifacts *Artifacts) GroupByPlatform() map[string][]*Artifact

GroupByPlatform groups the artifacts by their platform.

func (*Artifacts) List

func (artifacts *Artifacts) List() []*Artifact

List return the actual list of artifacts.

func (*Artifacts) Paths added in v0.154.0

func (artifacts *Artifacts) Paths() []string

Paths returns the artifact.Path of the current artifact list.

func (*Artifacts) Refresh added in v1.25.0

func (artifacts *Artifacts) Refresh() error

Refresh visits all artifacts and refreshes them.

func (*Artifacts) Remove added in v0.182.0

func (artifacts *Artifacts) Remove(filter Filter) error

Remove removes artifacts that match the given filter from the original artifact list.

func (*Artifacts) Visit added in v1.2.0

func (artifacts *Artifacts) Visit(fn VisitFn) error

Visit executes the given function for each artifact in the list.

type Extras added in v1.2.0

type Extras map[string]any

Extras represents the extra fields in an artifact.

func (Extras) MarshalJSON added in v1.2.0

func (e Extras) MarshalJSON() ([]byte, error)

type Filter

type Filter func(a *Artifact) bool

Filter defines an artifact filter which can be used within the Filter function.

func And

func And(filters ...Filter) Filter

And performs an AND between all given filters.

func ByBinaryLikeArtifacts added in v1.6.0

func ByBinaryLikeArtifacts(arts *Artifacts) Filter

ByBinaryLikeArtifacts filter artifacts down to artifacts that are Binary, UploadableBinary, or UniversalBinary, deduplicating artifacts by path (preferring UploadableBinary over all others). Note: this filter is unique in the sense that it cannot act in isolation of the state of other artifacts; the filter requires the whole list of artifacts in advance to perform deduplication.

func ByExt added in v1.7.0

func ByExt(exts ...string) Filter

ByExt filter artifact by their 'Ext' extra field.

func ByFormats added in v0.110.0

func ByFormats(formats ...string) Filter

ByFormats filters artifacts by a `Format` extra field.

func ByGoamd64 added in v1.8.0

func ByGoamd64(s string) Filter

ByGoamd64 is a predefined filter that filters by the given goamd64.

func ByGoarch

func ByGoarch(s string) Filter

ByGoarch is a predefined filter that filters by the given goarch.

func ByGoarm

func ByGoarm(s string) Filter

ByGoarm is a predefined filter that filters by the given goarm.

func ByGoos

func ByGoos(s string) Filter

ByGoos is a predefined filter that filters by the given goos.

func ByIDs added in v0.106.0

func ByIDs(ids ...string) Filter

ByIDs filter artifacts by an `ID` extra field.

func ByType

func ByType(t Type) Filter

ByType is a predefined filter that filters by the given type.

func Or

func Or(filters ...Filter) Filter

Or performs an OR between all given filters.

type Type

type Type int

Type defines the type of an artifact.

const (
	// UploadableArchive a tar.gz/zip archive to be uploaded.
	UploadableArchive Type = iota + 1
	// UploadableBinary is a binary file to be uploaded.
	UploadableBinary
	// UploadableFile is any file that can be uploaded.
	UploadableFile
	// Binary is a binary (output of a gobuild).
	Binary
	// UniversalBinary is a binary that contains multiple binaries within.
	UniversalBinary
	// LinuxPackage is a linux package generated by nfpm.
	LinuxPackage
	// PublishableSnapcraft is a snap package yet to be published.
	PublishableSnapcraft
	// Snapcraft is a published snap package.
	Snapcraft
	// PublishableDockerImage is a Docker image yet to be published.
	PublishableDockerImage
	// DockerImage is a published Docker image.
	DockerImage
	// DockerManifest is a published Docker manifest.
	DockerManifest
	// Checksum is a checksums file.
	Checksum
	// Signature is a signature file.
	Signature
	// Certificate is a signing certificate file
	Certificate
	// UploadableSourceArchive is the archive with the current commit source code.
	UploadableSourceArchive
	// BrewTap is an uploadable homebrew tap recipe file.
	BrewTap
	// Nixpkg is an uploadable nix package.
	Nixpkg
	// WingetInstaller winget installer file.
	WingetInstaller
	// WingetDefaultLocale winget default locale file.
	WingetDefaultLocale
	// WingetVersion winget version file.
	WingetVersion
	// PkgBuild is an Arch Linux AUR PKGBUILD file.
	PkgBuild
	// SrcInfo is an Arch Linux AUR .SRCINFO file.
	SrcInfo
	// KrewPluginManifest is a krew plugin manifest file.
	KrewPluginManifest
	// ScoopManifest is an uploadable scoop manifest file.
	ScoopManifest
	// SBOM is a Software Bill of Materials file.
	SBOM
	// PublishableChocolatey is a chocolatey package yet to be published.
	PublishableChocolatey
	// Header is a C header file, generated for CGo library builds.
	Header
	// CArchive is a C static library, generated via a CGo build with buildmode=c-archive.
	CArchive
	// CShared is a C shared library, generated via a CGo build with buildmode=c-shared.
	CShared
	// Metadata is an internal goreleaser metadata JSON file.
	Metadata
)

If you add more types, update TestArtifactTypeStringer!

func (Type) String added in v0.87.0

func (t Type) String() string

type VisitFn added in v1.2.0

type VisitFn func(a *Artifact) error

VisitFn is a function that can be executed against each artifact in a list.

Jump to

Keyboard shortcuts

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