mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-20 03:59:26 +02:00
fix: do not copy binary by default (#2916)
* fix: do not copy binary by default closes #2913 Signed-off-by: Carlos A Becker <caarlos0@gmail.com> * chore: ref Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
parent
99547865e1
commit
d6813ce54d
@ -94,7 +94,7 @@ defaulting to the current's machine target if not set.
|
||||
cmd.Flags().BoolVar(&root.opts.singleTarget, "single-target", false, "Builds only for current GOOS and GOARCH")
|
||||
cmd.Flags().StringVar(&root.opts.id, "id", "", "Builds only the specified build id")
|
||||
cmd.Flags().BoolVar(&root.opts.deprecated, "deprecated", false, "Force print the deprecation message - tests only")
|
||||
cmd.Flags().StringVarP(&root.opts.output, "output", "o", "", "Path to the binary, defaults to the distribution folder according to configs. Only taked into account when using --single-target and a single id (either with --id or if config only has one build)")
|
||||
cmd.Flags().StringVarP(&root.opts.output, "output", "o", "", "Copy the binary to thie path after the build. Only taked into account when using --single-target and a single id (either with --id or if config only has one build)")
|
||||
_ = cmd.Flags().MarkHidden("deprecated")
|
||||
|
||||
root.cmd = cmd
|
||||
@ -129,7 +129,7 @@ func buildProject(options buildOpts) (*context.Context, error) {
|
||||
}
|
||||
|
||||
func setupPipeline(ctx *context.Context, options buildOpts) []pipeline.Piper {
|
||||
if options.singleTarget && (options.id != "" || len(ctx.Config.Builds) == 1) {
|
||||
if options.output != "" && options.singleTarget && (options.id != "" || len(ctx.Config.Builds) == 1) {
|
||||
return append(pipeline.BuildCmdPipeline, withOutputPipe{options.output})
|
||||
}
|
||||
return pipeline.BuildCmdPipeline
|
||||
@ -216,7 +216,7 @@ func (w withOutputPipe) String() string {
|
||||
func (w withOutputPipe) Run(ctx *context.Context) error {
|
||||
path := ctx.Artifacts.Filter(artifact.ByType(artifact.Binary)).List()[0].Path
|
||||
out := w.output
|
||||
if out == "" {
|
||||
if out == "." {
|
||||
out = filepath.Base(path)
|
||||
}
|
||||
return gio.Copy(path, out)
|
||||
|
@ -63,7 +63,7 @@ func TestSetupPipeline(t *testing.T) {
|
||||
t.Run("single-target and id", func(t *testing.T) {
|
||||
require.Equal(
|
||||
t,
|
||||
append(pipeline.BuildCmdPipeline, withOutputPipe{""}),
|
||||
pipeline.BuildCmdPipeline,
|
||||
setupPipeline(context.New(config.Project{}), buildOpts{
|
||||
singleTarget: true,
|
||||
id: "foo",
|
||||
@ -71,10 +71,22 @@ func TestSetupPipeline(t *testing.T) {
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("single-target and id, given output", func(t *testing.T) {
|
||||
require.Equal(
|
||||
t,
|
||||
append(pipeline.BuildCmdPipeline, withOutputPipe{"foobar"}),
|
||||
setupPipeline(context.New(config.Project{}), buildOpts{
|
||||
singleTarget: true,
|
||||
id: "foo",
|
||||
output: ".",
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("single-target and single build on config", func(t *testing.T) {
|
||||
require.Equal(
|
||||
t,
|
||||
append(pipeline.BuildCmdPipeline, withOutputPipe{""}),
|
||||
pipeline.BuildCmdPipeline,
|
||||
setupPipeline(
|
||||
context.New(config.Project{
|
||||
Builds: []config.Build{{}},
|
||||
|
Loading…
x
Reference in New Issue
Block a user