mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-31 01:53:50 +02:00
feat: allow multiple ids on universal binaries (#2811)
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
parent
35b439a28a
commit
4a4c5ec5a6
@ -34,6 +34,9 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
if unibin.ID == "" {
|
||||
unibin.ID = ctx.Config.ProjectName
|
||||
}
|
||||
if len(unibin.IDs) == 0 {
|
||||
unibin.IDs = []string{unibin.ID}
|
||||
}
|
||||
if unibin.NameTemplate == "" {
|
||||
unibin.NameTemplate = "{{ .ProjectName }}"
|
||||
}
|
||||
@ -228,6 +231,6 @@ func filterFor(unibin config.UniversalBinary) artifact.Filter {
|
||||
return artifact.And(
|
||||
artifact.ByType(artifact.Binary),
|
||||
artifact.ByGoos("darwin"),
|
||||
artifact.ByIDs(unibin.ID),
|
||||
artifact.ByIDs(unibin.IDs...),
|
||||
)
|
||||
}
|
||||
|
@ -32,6 +32,24 @@ func TestDefault(t *testing.T) {
|
||||
require.NoError(t, Pipe{}.Default(ctx))
|
||||
require.Equal(t, config.UniversalBinary{
|
||||
ID: "proj",
|
||||
IDs: []string{"proj"},
|
||||
NameTemplate: "{{ .ProjectName }}",
|
||||
}, ctx.Config.UniversalBinaries[0])
|
||||
})
|
||||
|
||||
t.Run("given ids", func(t *testing.T) {
|
||||
ctx := &context.Context{
|
||||
Config: config.Project{
|
||||
ProjectName: "proj",
|
||||
UniversalBinaries: []config.UniversalBinary{
|
||||
{IDs: []string{"foo"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
require.NoError(t, Pipe{}.Default(ctx))
|
||||
require.Equal(t, config.UniversalBinary{
|
||||
ID: "proj",
|
||||
IDs: []string{"foo"},
|
||||
NameTemplate: "{{ .ProjectName }}",
|
||||
}, ctx.Config.UniversalBinaries[0])
|
||||
})
|
||||
@ -48,6 +66,7 @@ func TestDefault(t *testing.T) {
|
||||
require.NoError(t, Pipe{}.Default(ctx))
|
||||
require.Equal(t, config.UniversalBinary{
|
||||
ID: "foo",
|
||||
IDs: []string{"foo"},
|
||||
NameTemplate: "{{ .ProjectName }}",
|
||||
}, ctx.Config.UniversalBinaries[0])
|
||||
})
|
||||
@ -64,6 +83,7 @@ func TestDefault(t *testing.T) {
|
||||
require.NoError(t, Pipe{}.Default(ctx))
|
||||
require.Equal(t, config.UniversalBinary{
|
||||
ID: "proj",
|
||||
IDs: []string{"proj"},
|
||||
NameTemplate: "foo",
|
||||
}, ctx.Config.UniversalBinaries[0])
|
||||
})
|
||||
@ -111,6 +131,7 @@ func TestRun(t *testing.T) {
|
||||
UniversalBinaries: []config.UniversalBinary{
|
||||
{
|
||||
ID: "foo",
|
||||
IDs: []string{"foo"},
|
||||
NameTemplate: "foo",
|
||||
Replace: true,
|
||||
},
|
||||
@ -123,6 +144,7 @@ func TestRun(t *testing.T) {
|
||||
UniversalBinaries: []config.UniversalBinary{
|
||||
{
|
||||
ID: "foo",
|
||||
IDs: []string{"foo"},
|
||||
NameTemplate: "foo",
|
||||
},
|
||||
},
|
||||
@ -133,6 +155,7 @@ func TestRun(t *testing.T) {
|
||||
UniversalBinaries: []config.UniversalBinary{
|
||||
{
|
||||
ID: "notfoo",
|
||||
IDs: []string{"notfoo"},
|
||||
NameTemplate: "notfoo",
|
||||
},
|
||||
},
|
||||
@ -143,6 +166,7 @@ func TestRun(t *testing.T) {
|
||||
UniversalBinaries: []config.UniversalBinary{
|
||||
{
|
||||
ID: "foo",
|
||||
IDs: []string{"foo"},
|
||||
NameTemplate: "foo",
|
||||
},
|
||||
},
|
||||
@ -153,6 +177,7 @@ func TestRun(t *testing.T) {
|
||||
UniversalBinaries: []config.UniversalBinary{
|
||||
{
|
||||
ID: "foo",
|
||||
IDs: []string{"foo"},
|
||||
NameTemplate: "foo",
|
||||
Hooks: config.BuildHookConfig{
|
||||
Pre: []config.Hook{
|
||||
|
@ -435,7 +435,8 @@ func (f File) JSONSchemaType() *jsonschema.Type {
|
||||
|
||||
// UniversalBinary setups macos universal binaries.
|
||||
type UniversalBinary struct {
|
||||
ID string `yaml:"id,omitempty"`
|
||||
ID string `yaml:"id,omitempty"` // deprecated
|
||||
IDs []string `yaml:"ids,omitempty"`
|
||||
NameTemplate string `yaml:"name_template,omitempty"`
|
||||
Replace bool `yaml:"replace,omitempty"`
|
||||
Hooks BuildHookConfig `yaml:"hooks,omitempty"`
|
||||
|
@ -9,11 +9,18 @@ Here's how to use it:
|
||||
# .goreleaser.yaml
|
||||
universal_binaries:
|
||||
-
|
||||
# ID of the source build
|
||||
# ID of resulting universal binary.
|
||||
#
|
||||
# Defaults to the project name.
|
||||
id: foo
|
||||
|
||||
# IDs to use to filter the built binaries.
|
||||
#
|
||||
# Defaults to the `id` field.
|
||||
ids:
|
||||
- build1
|
||||
- build2
|
||||
|
||||
# Universal binary name template.
|
||||
#
|
||||
# You will want to change this if you have multiple builds!
|
||||
|
Loading…
Reference in New Issue
Block a user