You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-09-16 09:26:52 +02:00
support for custom build flags
This commit is contained in:
@@ -169,9 +169,14 @@ build:
|
|||||||
# Default is `main.go`
|
# Default is `main.go`
|
||||||
main: ./cmd/main.go
|
main: ./cmd/main.go
|
||||||
|
|
||||||
# Name of the binary. Default is the name of the project directory.
|
# Name of the binary.
|
||||||
|
# Default is the name of the project directory.
|
||||||
binary_name: program
|
binary_name: program
|
||||||
|
|
||||||
|
# Custom build tags.
|
||||||
|
# Default is empty
|
||||||
|
flags: -tags dev
|
||||||
|
|
||||||
# Custom ldflags.
|
# Custom ldflags.
|
||||||
# Default is `-s -w`
|
# Default is `-s -w`
|
||||||
ldflags: -s -w
|
ldflags: -s -w
|
||||||
|
@@ -28,6 +28,7 @@ type Build struct {
|
|||||||
Goarch []string
|
Goarch []string
|
||||||
Main string
|
Main string
|
||||||
Ldflags string
|
Ldflags string
|
||||||
|
Flags string
|
||||||
BinaryName string `yaml:"binary_name"`
|
BinaryName string `yaml:"binary_name"`
|
||||||
Hooks Hooks
|
Hooks Hooks
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,11 @@ func build(name, goos, goarch string, ctx *context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd := []string{"go", "build", "-ldflags=" + ldflags, "-o", output, ctx.Config.Build.Main}
|
cmd := []string{"go", "build"}
|
||||||
|
if ctx.Config.Build.Flags != "" {
|
||||||
|
cmd = append(cmd, strings.Split(ctx.Config.Build.Flags, " ")...)
|
||||||
|
}
|
||||||
|
cmd = append(cmd, "-ldflags="+ldflags, "-o", output, ctx.Config.Build.Main)
|
||||||
if err := run(goos, goarch, cmd); err != nil {
|
if err := run(goos, goarch, cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user