Skip to content

Commit

Permalink
feat: remove singular snapcraft config (#1281)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Dec 27, 2019
1 parent 885a971 commit 468401b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 43 deletions.
13 changes: 3 additions & 10 deletions internal/pipe/snapcraft/snapcraft.go
Expand Up @@ -7,21 +7,20 @@ import (
"os"
"os/exec"
"path/filepath"
"reflect"
"strings"

"github.com/apex/log"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"

"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"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/pkg/errors"
yaml "gopkg.in/yaml.v2"
)

// ErrNoSnapcraft is shown when snapcraft cannot be found in $PATH
Expand Down Expand Up @@ -67,12 +66,6 @@ func (Pipe) String() string {

// Default sets the pipe defaults
func (Pipe) Default(ctx *context.Context) error {
if len(ctx.Config.Snapcrafts) == 0 {
ctx.Config.Snapcrafts = append(ctx.Config.Snapcrafts, ctx.Config.Snapcraft)
if !reflect.DeepEqual(ctx.Config.Snapcraft, config.Snapcraft{}) {
deprecate.Notice("snapcraft")
}
}
var ids = ids.New("snapcrafts")
for i := range ctx.Config.Snapcrafts {
var snap = &ctx.Config.Snapcrafts[i]
Expand Down
13 changes: 3 additions & 10 deletions internal/pipe/snapcraft/snapcraft_test.go
Expand Up @@ -326,6 +326,9 @@ func TestDefault(t *testing.T) {
ID: "foo",
},
},
Snapcrafts: []config.Snapcraft{
{},
},
})
assert.NoError(t, Pipe{}.Default(ctx))
assert.Equal(t, defaultNameTemplate, ctx.Config.Snapcrafts[0].NameTemplate)
Expand Down Expand Up @@ -357,16 +360,6 @@ func TestDefaultSet(t *testing.T) {
assert.Equal(t, "foo", ctx.Config.Snapcrafts[0].NameTemplate)
}

func TestDefaultDeprecate(t *testing.T) {
var ctx = context.New(config.Project{
Snapcraft: config.Snapcraft{
NameTemplate: "foo",
},
})
assert.NoError(t, Pipe{}.Default(ctx))
assert.Equal(t, "foo", ctx.Config.Snapcrafts[0].NameTemplate)
}

func addBinaries(t *testing.T, ctx *context.Context, name, dist, dest string) {
for _, goos := range []string{"linux", "darwin"} {
for _, goarch := range []string{"amd64", "386", "arm6"} {
Expand Down
1 change: 0 additions & 1 deletion pkg/config/config.go
Expand Up @@ -361,7 +361,6 @@ type Project struct {
Archive Archive `yaml:",omitempty"` // TODO: remove this
Archives []Archive `yaml:",omitempty"`
NFPMs []NFPM `yaml:"nfpms,omitempty"`
Snapcraft Snapcraft `yaml:",omitempty"` // TODO: remove this
Snapcrafts []Snapcraft `yaml:",omitempty"`
Snapshot Snapshot `yaml:",omitempty"`
Checksum Checksum `yaml:",omitempty"`
Expand Down
45 changes: 23 additions & 22 deletions www/content/deprecations.md
Expand Up @@ -175,54 +175,55 @@ blobs:
# etc
```

### snapcraft
### archive

> since 2019-05-27
> since 2019-04-16
We now allow multiple Snapcraft configs, so the `snapcraft` statement will be removed.
We now allow multiple archives, so the `archive` statement will be removed.

Change this:

```yaml
snapcraft:
publish: true
# ...
archive:
format: zip
```

to this:

```yaml
snapcrafts:
-
publish: true
# ...
archives:
- id: foo
format: zip
```

### archive
## Expired deprecation notices

> since 2019-04-16
The following options were deprecated for ~6 months and are now fully removed.

We now allow multiple archives, so the `archive` statement will be removed.

### snapcraft

> since 2019-05-27, removed 2019-12-27
We now allow multiple Snapcraft configs, so the `snapcraft` statement will be removed.

Change this:

```yaml
archive:
format: zip
snapcraft:
publish: true
# ...
```

to this:

```yaml
archives:
- id: foo
format: zip
snapcrafts:
-
publish: true
# ...
```

## Expired deprecation notices

The following options were deprecated for ~6 months and are now fully removed.

### nfpm

> since 2019-05-07, removed 2019-12-27
Expand Down

0 comments on commit 468401b

Please sign in to comment.