build

package
v1.8.73 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: Zlib Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &Builder{}

Default builder instance.

Functions

This section is empty.

Types

type Build

type Build struct {
	ID               string                          `yaml:"id,omitempty" json:"id,omitempty"`
	Goos             []string                        `yaml:"goos,omitempty" json:"goos,omitempty"`
	Goarch           []string                        `yaml:"goarch,omitempty" json:"goarch,omitempty"`
	Goarm            []string                        `yaml:"goarm,omitempty" json:"goarm,omitempty"`
	Gomips           []string                        `yaml:"gomips,omitempty" json:"gomips,omitempty"`
	Goamd64          []string                        `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
	Ignore           []IgnoredBuild                  `yaml:"ignore,omitempty" json:"ignore,omitempty"`
	ModulePath       string                          `yaml:"module_path" json:"module_path"`
	Target           string                          `yaml:"target,omitempty" json:"target,omitempty"`
	ProjectName      string                          `yaml:"project_name" json:"project_name"`
	Dir              string                          `yaml:"dir,omitempty" json:"dir,omitempty"`
	Main             string                          `yaml:"main,omitempty" json:"main,omitempty"`
	GoBinary         string                          `yaml:"go_binary,omitempty" json:"go_binary,omitempty"`
	Command          string                          `yaml:"command,omitempty" json:"command,omitempty"`
	DetailsOverrides []DetailsOverride               `yaml:"overrides,omitempty" json:"overrides,omitempty"`
	Package          Package                         `yaml:"package" json:"package"`
	Details          `yaml:",inline" json:",inline"` // nolint: tagliatelle
}

Build contains the build configuration section.

type Builder

type Builder struct{}

Builder is golang builder.

func (*Builder) Build

func (*Builder) Build(ctx *Context, build Build, options Options) error

Build builds a golang build.

func (*Builder) Clean

func (*Builder) Clean(ctx *Context, build Build, options Options) error

func (*Builder) Package

func (*Builder) Package(ctx *Context, build Build, options Options) error

Package 打包

func (*Builder) WithDefaults

func (*Builder) WithDefaults(build Build) (Build, error)

WithDefaults sets the defaults for a golang build and returns it.

type Config

type Config struct {
	ProjectName string
	Version     string
	Env         []string
}

type Context

type Context struct {
	stdctx.Context
	Config Config
	Env    Env
	Git    Git
	Date   time.Time

	Snapshot bool
	Semver   Semver
	Runtime  Runtime
}

Context carries along some data through the pipes.

func NewContext

func NewContext(config Config) *Context

NewContext context.

func NewWithTimeout

func NewWithTimeout(config Config, timeout time.Duration) (*Context, stdctx.CancelFunc)

NewWithTimeout new context with the given timeout.

func WrapContext

func WrapContext(ctx stdctx.Context, config Config) *Context

WrapContext wraps an existing context.

type Details

type Details struct {
	Buildmode string      `yaml:"buildmode,omitempty" json:"buildmode,omitempty"`
	Ldflags   StringArray `yaml:"ldflags,omitempty" json:"ldflags,omitempty"`
	Tags      FlagArray   `yaml:"tags,omitempty" json:"tags,omitempty"`
	Flags     FlagArray   `yaml:"flags,omitempty" json:"flags,omitempty"`
	AsmFlags  StringArray `yaml:"asm_flags,omitempty" json:"asm_flags,omitempty"`
	GcFlags   StringArray `yaml:"gc_flags,omitempty" json:"gc_flags,omitempty"`
	Env       []string    `yaml:"env,omitempty" json:"env,omitempty"`
}

type DetailsOverride

type DetailsOverride struct {
	Goos    string                          `yaml:"goos,omitempty" json:"goos,omitempty"`
	Goarch  string                          `yaml:"goarch,omitempty" json:"goarch,omitempty"`
	Goarm   string                          `yaml:"goarm,omitempty" json:"goarm,omitempty" jsonschema:"oneof_type=string;integer"`
	Gomips  string                          `yaml:"gomips,omitempty" json:"gomips,omitempty"`
	Goamd64 string                          `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
	Details `yaml:",inline" json:",inline"` // nolint: tagliatelle
}

type Env

type Env map[string]string

Env is the environment variables.

func ToEnv

func ToEnv(env []string) Env

ToEnv converts a list of strings to an Env (aka a map[string]string).

func (Env) Copy

func (e Env) Copy() Env

Copy returns a copy of the environment.

func (Env) Strings

func (e Env) Strings() []string

Strings returns the current environment as a list of strings, suitable for os executions.

type Error

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

Error is returned on any template error.

func (Error) Error

func (e Error) Error() string

func (Error) Unwrap

func (e Error) Unwrap() error

type ExpectedSingleEnvErr

type ExpectedSingleEnvErr struct{}

func (ExpectedSingleEnvErr) Error

func (e ExpectedSingleEnvErr) Error() string

type Fields

type Fields map[string]interface{}

Fields that will be available to the template engine.

type FlagArray

type FlagArray []string

type Git

type Git struct {
	Branch      string
	CurrentTag  string
	PreviousTag string
	Commit      string
	ShortCommit string
	FullCommit  string
	FirstCommit string
	CommitDate  time.Time
	URL         string
	Summary     string
	TagSubject  string
	TagContents string
	TagBody     string
	Dirty       bool
}

Git includes tags and diffs used in some point.

type IgnoredBuild

type IgnoredBuild struct {
	Goos   string `yaml:"goos,omitempty" json:"goos,omitempty"`
	Goarch string `yaml:"goarch,omitempty" json:"goarch,omitempty"`
}

IgnoredBuild represents a build ignored by the user.

type Options

type Options struct {
	Name    string
	Path    string
	Ext     string
	Target  string
	Goos    string
	Goarch  string
	Goamd64 string
	Goarm   string
	Gomips  string
}

Options to be passed down to a builder.

type Package

type Package struct {
	Os      string   `yaml:"os" json:"os"`
	Model   string   `yaml:"model" json:"model"`     //prod, test, dev
	Format  string   `yaml:"format" json:"format"`   //zip, tar.gz, tgz, tar, cab(windows), setup
	Dist    string   `yaml:"dist" json:"dist"`       //输出目录
	Version int      `yaml:"version" json:"version"` //0:输出文件名后+“-版本号”,1:不需要版本号; 2 压缩文件前带版本号
	Ignore  []string `yaml:"ignore" json:"ignore"`
}

func (*Package) InIgnore

func (p *Package) InIgnore(s string, isDir bool) bool

type Runtime

type Runtime struct {
	Goos   string
	Goarch string
}

type Semver

type Semver struct {
	Major      uint64
	Minor      uint64
	Patch      uint64
	Prerelease string
}

Semver represents a semantic version.

type StringArray

type StringArray []string

StringArray is a wrapper for an array of strings.

type Template

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

Template holds data that can be applied to a template string.

func NewTemplate

func NewTemplate(ctx *Context) *Template

NewTemplate Template.

func (*Template) Apply

func (t *Template) Apply(s string) (string, error)

Apply applies the given string against the Fields stored in the template.

func (*Template) ApplyAll

func (t *Template) ApplyAll(sps ...*string) error

ApplyAll applies all the given strings against the Fields stored in the template. Application stops as soon as an error is encountered.

func (*Template) ApplySingleEnvOnly

func (t *Template) ApplySingleEnvOnly(s string) (string, error)

ApplySingleEnvOnly enforces template to only contain a single environment variable and nothing else.

func (*Template) Bool

func (t *Template) Bool(s string) (bool, error)

Bool Apply the given string, and converts it to a bool.

func (*Template) WithBuildOptions

func (t *Template) WithBuildOptions(opts Options) *Template

func (*Template) WithEnv

func (t *Template) WithEnv(e map[string]string) *Template

WithEnv overrides template's env field with the given environment map.

func (*Template) WithEnvS

func (t *Template) WithEnvS(envs []string) *Template

WithEnvS overrides template's env field with the given KEY=VALUE list of environment variables.

func (*Template) WithExtraFields

func (t *Template) WithExtraFields(f Fields) *Template

WithExtraFields allows to add new more custom fields to the template. It will override fields with the same name.

Jump to

Keyboard shortcuts

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