mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-29 01:44:39 +02:00
parent
7e809382df
commit
d355350f63
@ -13,6 +13,7 @@ import (
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
"github.com/goreleaser/goreleaser/internal/deprecate"
|
||||
"github.com/goreleaser/goreleaser/internal/ids"
|
||||
"github.com/goreleaser/goreleaser/internal/linux"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe"
|
||||
"github.com/goreleaser/goreleaser/internal/semerrgroup"
|
||||
@ -71,6 +72,7 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
deprecate.Notice("snapcraft")
|
||||
}
|
||||
}
|
||||
var ids = ids.New()
|
||||
for i := range ctx.Config.Snapcrafts {
|
||||
var snap = &ctx.Config.Snapcrafts[i]
|
||||
if snap.NameTemplate == "" {
|
||||
@ -81,8 +83,9 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
snap.Builds = append(snap.Builds, b.ID)
|
||||
}
|
||||
}
|
||||
ids.Inc(snap.ID)
|
||||
}
|
||||
return nil
|
||||
return ids.Validate()
|
||||
}
|
||||
|
||||
// Run the pipe
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/pkg/config"
|
||||
"github.com/goreleaser/goreleaser/pkg/context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
@ -313,3 +314,19 @@ func addBinaries(t *testing.T, ctx *context.Context, name, dist, dest string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSeveralSnapssWithTheSameID(t *testing.T) {
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
Snapcrafts: []config.Snapcraft{
|
||||
{
|
||||
ID: "a",
|
||||
},
|
||||
{
|
||||
ID: "a",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
require.EqualError(t, Pipe{}.Default(ctx), "found 2 items with the ID 'a', please fix your config")
|
||||
}
|
||||
|
@ -226,6 +226,7 @@ type Snapcraft struct {
|
||||
Replacements map[string]string `yaml:",omitempty"`
|
||||
Publish bool `yaml:",omitempty"`
|
||||
|
||||
ID string `yaml:",omitempty"`
|
||||
Builds []string `yaml:",omitempty"`
|
||||
Name string `yaml:",omitempty"`
|
||||
Summary string `yaml:",omitempty"`
|
||||
|
@ -20,6 +20,10 @@ Available options:
|
||||
# .goreleaser.yml
|
||||
snapcrafts:
|
||||
-
|
||||
# ID of the nfpm config, must be unique.
|
||||
# Defaults to "default".
|
||||
id: foo
|
||||
|
||||
# Build IDs for the builds you want to create snapcraft packages for.
|
||||
# Defaults to all builds.
|
||||
builds:
|
||||
|
Loading…
Reference in New Issue
Block a user