build

package
v1.20.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Zlib Imports: 22 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"`
	ModulePath  string                          `yaml:"module_path" json:"module_path"`
	ProductId   string                          `yaml:"product_id" json:"product_id"`
	ProjectName string                          `yaml:"project_name" json:"project_name"`
	Target      string                          `yaml:"target,omitempty" json:"target,omitempty"`
	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"`
	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, opts Options) error

Build builds a golang build.

func (*Builder) Clean

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

func (*Builder) Package

func (b *Builder) Package(ctx *Context, build Build, out *PackOut, onlyNeedPackOut bool) 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 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 IgnoreCheck added in v1.8.76

type IgnoreCheck func(path, name string, isDir bool) bool

type Options

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

Options to be passed down to a builder.

type PackCompleted added in v1.8.76

type PackCompleted func(out *PackOut, pf *PackFile, completed bool)

type PackFile added in v1.8.75

type PackFile struct {
	Name string `json:"name"`
	MD5  string `json:"md5"`
	Size int64  `json:"size"`
	Url  string `json:"url,omitempty"`
}

type PackOut added in v1.9.14

type PackOut struct {
	Name   string
	Path   string
	Ext    string
	Target string
}

type Package

type Package struct {
	Os          string   `yaml:"os" json:"os"`
	ProductCode string   `yaml:"product_code" json:"product_code"`
	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"`           //输出目录
	OutFile     string   `yaml:"out_file" json:"out_file"`   //输出文件名,可以为空
	HashFile    string   `yaml:"hash_file" json:"hash_file"` //输出pack 总的包描述文件,如: updates.json
	BaseUrl     string   `yaml:"base_url" json:"base_url"`
	Ignore      []string `yaml:"ignore" json:"ignore"`
	ModelIf     int      `yaml:"model_if" json:"model_if"` //输出文件名,带model信息
	OsIf        int      `yaml:"os_if" json:"os_if"`       //输出文件名,带os信息
	Version     int      `yaml:"version" json:"version"`   //0:输出文件名后+“-版本号”,1:不需要版本号; 2 压缩文件前带版本号
	Hash        int      `yaml:"hash" json:"hash"`         //0 不输出, 1 输出所有原文件 md5 hash描述文件
	// contains filtered or unexported fields
}

func (*Package) InIgnore

func (p *Package) InIgnore(path, name string, isDir bool) bool

func (*Package) WithCompleted added in v1.8.99

func (p *Package) WithCompleted(check PackCompleted)

func (*Package) WithIgnoreCheck added in v1.8.99

func (p *Package) WithIgnoreCheck(check IgnoreCheck)

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.

type UpdateFile added in v1.8.75

type UpdateFile struct {
	Os          string     `json:"os"`
	Version     string     `json:"version"`
	Model       string     `json:"model"`
	ProductId   string     `json:"product_id"`
	ProductCode string     `json:"product_code"`
	ProjectName string     `json:"project_name"`
	Packs       []PackFile `json:"packs"`
}

Jump to

Keyboard shortcuts

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