Documentation ¶
Index ¶
- Constants
- Variables
- func AddFlag(f string, bit int)
- func DefaultDateFormat(d time.Time) string
- func GetFlag(f string) int
- type Bit
- type Build
- type Builder
- func (*Builder) Build(ctx *Context, build Build, opts Options) error
- func (b *Builder) BuildHashFileName(ctx *Context, bit Bit, filename string) string
- func (b *Builder) BuildTargetFileName(ctx *Context, bit Bit, filename string) string
- func (*Builder) Clean(ctx *Context, build Build, options Options) error
- func (b *Builder) Package(ctx *Context, build Build, out *PackOut) error
- func (*Builder) WithDefaults(build Build) (Build, error)
- type Config
- type Context
- type DateFormatFunc
- type Details
- type Env
- type Error
- type ExpectedSingleEnvErr
- type Fields
- type FlagArray
- type Git
- type HashFile
- type Options
- type PackCheck
- type PackCompleted
- type PackFile
- type PackOut
- type Package
- func (p *Package) CheckOs(name string) bool
- func (p *Package) ExcludeCheck(path, name string, isDir bool) bool
- func (p *Package) Ignore(path, name string, isDir bool) bool
- func (p *Package) IncludeCheck(path, name string, isDir bool) bool
- func (p *Package) IsFlag(o int32) bool
- func (p *Package) Parse()
- func (p *Package) WithCompleted(check PackCompleted)
- func (p *Package) WithExcludeCheck(check PackCheck)
- func (p *Package) WithIncludeCheck(check PackCheck)
- type Regex
- type Runtime
- type Semver
- type StringArray
- type Template
- func (t *Template) AddField(key string, value interface{}) *Template
- func (t *Template) Apply(s string) (string, error)
- func (t *Template) ApplyAll(in ...string) ([]string, error)
- func (t *Template) ApplySingleEnvOnly(s string) (string, error)
- func (t *Template) Bool(s string) (bool, error)
- func (t *Template) WithBuildOptions(opts Options) *Template
- func (t *Template) WithEnv(e map[string]string) *Template
- func (t *Template) WithEnvS(envs []string) *Template
- func (t *Template) WithExtraFields(f Fields) *Template
Constants ¶
const ( OutHashFile = 0x00001 // 输出updates.json(hash文件) HashNeedProject = 0x00002 // hash文件需要用程序名 HashNeedVersion = 0x00004 // hash文件需要带版本号 HashNeedModel = 0x00008 // hash输出带model HashNeedOs = 0x00010 // hash输出带os TargetNeedVersion = 0x00020 TargetNeedModel = 0x00040 TargetNeedOs = 0x00080 TargetNeedDate = 0x00100 NeedArchiveHash = 0x02000 // hashFile需要添加到压缩文件中 OnlyPackOut = 0x04000 NotArchive = 0x08000 //不需要压缩 ArchiveVersion = 0x10000 //压缩目录带版本 ArchiveProject = 0x20000 //压缩目录带产品名(ProjectName) NotCheckTpl = 0x40000 //不需要检测模板 *.tpl NotCheckPackFile = 0x80000 //不对 exclude, include 检测 )
const ( RegexPrefix = "regex|" PathPrefix = "path|" )
Variables ¶
var Default = &Builder{}
Default builder instance.
Functions ¶
func DefaultDateFormat ¶ added in v1.20.55
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"` Executor map[string]string `yaml:"executor" json:"executor"` //生成的执行文件名,不同的操作系统对应不同的执行文件,"drawin":"projectName-mac",“linux":"projectName-linux","windows":"projectName-win.exe" 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) BuildHashFileName ¶ added in v1.20.42
func (*Builder) BuildTargetFileName ¶ added in v1.20.49
type Context ¶
type Context struct { stdctx.Context Config Config Env Env Git Git Semver Semver Runtime Runtime DateFormat DateFormatFunc Date time.Time Snapshot bool }
Context carries along some data through the pipes.
func NewWithTimeout ¶
NewWithTimeout new context with the given timeout.
type DateFormatFunc ¶ added in v1.20.55
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 ¶
Env is the environment variables.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is returned on any template 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 Git ¶
type Git struct { Branch string CurrentTag string PreviousTag string Commit string ShortCommit string FullCommit string FirstCommit string URL string Summary string TagSubject string TagContents string TagBody string CommitDate time.Time Dirty bool }
Git includes tags and diffs used in some point.
type PackCompleted ¶ added in v1.8.76
type PackOut ¶ added in v1.9.14
type PackOut struct { Version string `json:"version"` Path string `json:"path"` // ./build PackagePath string `json:"packagePath"` PublishPath string `json:"publishPath"` Name string `json:"name"` // file name Ext string `json:"ext"` // file ext Target string `json:"target"` Url string `json:"url"` Hash string `json:"hash"` // updates.json 文件名(包括路径) Data interface{} `json:"-"` //自定义 }
type Package ¶
type Package struct { ProductCode string `yaml:"productCode" json:"productCode"` //产品编号 Model string `yaml:"model" json:"model"` //prod, test, dev Os string `yaml:"os" json:"os"` //操作系统 windows,linux,darwin Format string `yaml:"format" json:"format"` //zip, tar.gz, tgz, tar, cab(windows), setup Dist string `yaml:"dist" json:"dist"` //输出目录 PackagePath string `yaml:"packagePath" json:"packagePath"` // 包目录 dist/package_path, 默认 dist/packages PublishPath string `yaml:"publishPath" json:"publishPath"` // 发布目录 dist/publish_path 默认 dist/publishes Target string `yaml:"target" json:"target"` //输出文件名,可以为空 Hash string `yaml:"hash" json:"hash"` //输出pack 总的包描述文件,如: updates.json BaseUrl string `yaml:"baseUrl" json:"baseUrl"` //文件存储基本地址(oss,如阿里云) MgrHost string `yaml:"mgrHost" json:"mgrHost"` //版本管理后台host,需要把打包的信息保存到后台进行管理,比如: http://xxx.com:port Flag string `yaml:"flag" json:"flag"` //标识 @see OutHashFile Exclude []string `yaml:"exclude" json:"exclude"` //打包不包括的选项 Include []string `yaml:"include" json:"include"` //打包包括的选项 // contains filtered or unexported fields }
func (*Package) ExcludeCheck ¶ added in v1.20.34
func (*Package) IncludeCheck ¶ added in v1.20.34
func (*Package) WithCompleted ¶ added in v1.8.99
func (p *Package) WithCompleted(check PackCompleted)
func (*Package) WithExcludeCheck ¶ added in v1.20.34
func (*Package) WithIncludeCheck ¶ added in v1.20.34
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template holds data that can be applied to a template string.
func NewEmptyTemplate ¶ added in v1.20.38
func NewEmptyTemplate() *Template
func (*Template) ApplyAll ¶
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 ¶
ApplySingleEnvOnly enforces template to only contain a single environment variable and nothing else.
func (*Template) WithBuildOptions ¶
func (*Template) WithEnvS ¶
WithEnvS overrides template's env field with the given KEY=VALUE list of environment variables.
func (*Template) WithExtraFields ¶
WithExtraFields allows to add new more custom fields to the template. It will override fields with the same name.