1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-27 01:33:39 +02:00

feat: --skip=archive (#4916)

closes #4905
This commit is contained in:
Carlos Alexandro Becker 2024-06-11 09:23:21 -03:00 committed by GitHub
parent 39e62beadc
commit f3fce3df5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import (
"github.com/goreleaser/goreleaser/v2/internal/artifact"
"github.com/goreleaser/goreleaser/v2/internal/ids"
"github.com/goreleaser/goreleaser/v2/internal/semerrgroup"
"github.com/goreleaser/goreleaser/v2/internal/skips"
"github.com/goreleaser/goreleaser/v2/internal/tmpl"
"github.com/goreleaser/goreleaser/v2/pkg/archive"
"github.com/goreleaser/goreleaser/v2/pkg/config"
@ -44,6 +45,10 @@ func (Pipe) String() string {
return "archives"
}
func (Pipe) Skip(ctx *context.Context) bool {
return skips.Any(ctx, skips.Archive)
}
// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
ids := ids.New("archives")

View File

@ -11,6 +11,7 @@ import (
"testing"
"github.com/goreleaser/goreleaser/v2/internal/artifact"
"github.com/goreleaser/goreleaser/v2/internal/skips"
"github.com/goreleaser/goreleaser/v2/internal/testctx"
"github.com/goreleaser/goreleaser/v2/internal/testlib"
"github.com/goreleaser/goreleaser/v2/pkg/archive"
@ -1228,3 +1229,13 @@ func TestExtraFormatWhenOverride(t *testing.T) {
archives := ctx.Artifacts.Filter(artifact.ByFormats("zip")).List()
require.Len(t, archives, 1)
}
func TestSkip(t *testing.T) {
t.Run("skip", func(t *testing.T) {
ctx := testctx.New(testctx.Skip(skips.Archive))
require.True(t, Pipe{}.Skip(ctx))
})
t.Run("dont skip", func(t *testing.T) {
require.False(t, Pipe{}.Skip(testctx.New()))
})
}

View File

@ -32,6 +32,7 @@ const (
NFPM Key = "nfpm"
Chocolatey Key = "chocolatey"
Notarize Key = "notarize"
Archive Key = "archive"
)
func String(ctx *context.Context) string {
@ -116,6 +117,7 @@ var Release = Keys{
NFPM,
Before,
Notarize,
Archive,
}
var Build = Keys{