1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00

fix: snapcraft: do not push when skip publish (#1374)

* fix: snapcraft: do not publish when skip publish

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: snapcraft: do not publish when skip publish

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2020-03-04 01:14:40 -03:00 committed by GitHub
parent 969fb4b804
commit 2e69fa0667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -141,6 +141,9 @@ func isValidArch(arch string) bool {
// Publish packages
func (Pipe) Publish(ctx *context.Context) error {
if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled
}
snaps := ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List()
var g = semerrgroup.New(ctx.Parallelism)
for _, snap := range snaps {

View File

@ -9,6 +9,7 @@ import (
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/assert"
@ -355,6 +356,19 @@ func TestPublish(t *testing.T) {
assert.Contains(t, err.Error(), "failed to push nope.snap package")
}
func TestPublishSkip(t *testing.T) {
var ctx = context.New(config.Project{})
ctx.SkipPublish = true
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: "nope.snap",
Goarch: "amd64",
Goos: "linux",
Type: artifact.PublishableSnapcraft,
})
testlib.AssertSkipped(t, Pipe{}.Publish(ctx))
}
func TestDefaultSet(t *testing.T) {
var ctx = context.New(config.Project{
Snapcrafts: []config.Snapcraft{