diff --git a/internal/builders/golang/build.go b/internal/builders/golang/build.go index 3cff392b4ef..6a10502a1ec 100644 --- a/internal/builders/golang/build.go +++ b/internal/builders/golang/build.go @@ -221,13 +221,15 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti a.Extra["testEnvs"] = testEnvs } - cmd, err := buildGoBuildLine(ctx, build, details, options, a, env) - if err != nil { - return err - } + if !options.PreBuilt { + cmd, err := buildGoBuildLine(ctx, build, details, options, a, env) + if err != nil { + return err + } - if err := run(ctx, cmd, env, build.Dir); err != nil { - return fmt.Errorf("failed to build for %s: %w", options.Target, err) + if err := run(ctx, cmd, env, build.Dir); err != nil { + return fmt.Errorf("failed to build for %s: %w", options.Target, err) + } } modTimestamp, err := tmpl.New(ctx).WithEnvS(env).WithArtifact(a).Apply(build.ModTimestamp) diff --git a/internal/pipe/build/build.go b/internal/pipe/build/build.go index c29527f9534..e606e18bc32 100644 --- a/internal/pipe/build/build.go +++ b/internal/pipe/build/build.go @@ -206,7 +206,13 @@ func buildOptionsForTarget(ctx *context.Context, build config.Build, target stri if build.NoUniqueDistDir { dir = "" } - relpath := filepath.Join(ctx.Config.Dist, dir, name) + + basePath := ctx.Config.Dist + if build.PreBuiltBinaryDir != "" { + basePath = build.PreBuiltBinaryDir + buildOpts.PreBuilt = true + } + relpath := filepath.Join(basePath, dir, name) path, err := filepath.Abs(relpath) if err != nil { return nil, err diff --git a/internal/pipe/release/scm_test.go b/internal/pipe/release/scm_test.go index 0a8e18ed217..43fcaf414a2 100644 --- a/internal/pipe/release/scm_test.go +++ b/internal/pipe/release/scm_test.go @@ -71,7 +71,7 @@ func TestSetupGitea(t *testing.T) { t.Run("no repo", func(t *testing.T) { ctx := testctx.New() require.NoError(t, setupGitea(ctx)) - require.Equal(t, "goreleaser", ctx.Config.Release.Gitea.Owner) + require.Equal(t, "cldcvr", ctx.Config.Release.Gitea.Owner) require.Equal(t, "goreleaser", ctx.Config.Release.Gitea.Name) }) @@ -127,7 +127,7 @@ func TestSetupGitHub(t *testing.T) { t.Run("no repo", func(t *testing.T) { ctx := testctx.New() require.NoError(t, setupGitHub(ctx)) - require.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Owner) + require.Equal(t, "cldcvr", ctx.Config.Release.GitHub.Owner) require.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Name) }) diff --git a/pkg/build/build.go b/pkg/build/build.go index 97112998085..995ff51b537 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -28,15 +28,16 @@ func For(name string) Builder { // Options to be passed down to a builder. type Options struct { - Name string - Path string - Ext string - Target string - Goos string - Goarch string - Goamd64 string - Goarm string - Gomips string + Name string + Path string + Ext string + Target string + Goos string + Goarch string + Goamd64 string + Goarm string + Gomips string + PreBuilt bool } // Builder defines a builder. diff --git a/pkg/config/config.go b/pkg/config/config.go index a6736565d3d..05ef248f82a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -493,27 +493,28 @@ func (a FlagArray) JSONSchema() *jsonschema.Schema { // Build contains the build configuration section. 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"` - Targets []string `yaml:"targets,omitempty" json:"targets,omitempty"` - Ignore []IgnoredBuild `yaml:"ignore,omitempty" json:"ignore,omitempty"` - Dir string `yaml:"dir,omitempty" json:"dir,omitempty"` - Main string `yaml:"main,omitempty" json:"main,omitempty"` - Binary string `yaml:"binary,omitempty" json:"binary,omitempty"` - Hooks BuildHookConfig `yaml:"hooks,omitempty" json:"hooks,omitempty"` - Builder string `yaml:"builder,omitempty" json:"builder,omitempty"` - ModTimestamp string `yaml:"mod_timestamp,omitempty" json:"mod_timestamp,omitempty"` - Skip bool `yaml:"skip,omitempty" json:"skip,omitempty"` - GoBinary string `yaml:"gobinary,omitempty" json:"gobinary,omitempty"` - Command string `yaml:"command,omitempty" json:"command,omitempty"` - NoUniqueDistDir bool `yaml:"no_unique_dist_dir,omitempty" json:"no_unique_dist_dir,omitempty"` - NoMainCheck bool `yaml:"no_main_check,omitempty" json:"no_main_check,omitempty"` - UnproxiedMain string `yaml:"-" json:"-"` // used by gomod.proxy - UnproxiedDir string `yaml:"-" json:"-"` // used by gomod.proxy + 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"` + Targets []string `yaml:"targets,omitempty" json:"targets,omitempty"` + Ignore []IgnoredBuild `yaml:"ignore,omitempty" json:"ignore,omitempty"` + Dir string `yaml:"dir,omitempty" json:"dir,omitempty"` + Main string `yaml:"main,omitempty" json:"main,omitempty"` + Binary string `yaml:"binary,omitempty" json:"binary,omitempty"` + Hooks BuildHookConfig `yaml:"hooks,omitempty" json:"hooks,omitempty"` + Builder string `yaml:"builder,omitempty" json:"builder,omitempty"` + ModTimestamp string `yaml:"mod_timestamp,omitempty" json:"mod_timestamp,omitempty"` + Skip bool `yaml:"skip,omitempty" json:"skip,omitempty"` + GoBinary string `yaml:"gobinary,omitempty" json:"gobinary,omitempty"` + Command string `yaml:"command,omitempty" json:"command,omitempty"` + NoUniqueDistDir bool `yaml:"no_unique_dist_dir,omitempty" json:"no_unique_dist_dir,omitempty"` + NoMainCheck bool `yaml:"no_main_check,omitempty" json:"no_main_check,omitempty"` + PreBuiltBinaryDir string `yaml:"prebuilt_binary_dir,omitempty" json:"prebuilt_binary_dir,omitempty"` + UnproxiedMain string `yaml:"-" json:"-"` // used by gomod.proxy + UnproxiedDir string `yaml:"-" json:"-"` // used by gomod.proxy BuildDetails `yaml:",inline" json:",inline"` // nolint: tagliatelle BuildDetailsOverrides []BuildDetailsOverride `yaml:"overrides,omitempty" json:"overrides,omitempty"` diff --git a/www/docs/static/schema.json b/www/docs/static/schema.json index 99a84820a19..375e46246ad 100644 --- a/www/docs/static/schema.json +++ b/www/docs/static/schema.json @@ -376,6 +376,9 @@ "no_main_check": { "type": "boolean" }, + "prebuilt_binary_dir": { + "type": "string" + }, "buildmode": { "type": "string" },