mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
refactor: release: pipe -> publisher
This commit is contained in:
parent
6d6d6ece8f
commit
dd81fec3dd
@ -10,7 +10,6 @@ import (
|
||||
"text/template"
|
||||
|
||||
"github.com/apex/log"
|
||||
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
"github.com/goreleaser/goreleaser/internal/client"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe"
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/fatih/color"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/brew"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/release"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/scoop"
|
||||
"github.com/goreleaser/goreleaser/pkg/context"
|
||||
"github.com/pkg/errors"
|
||||
@ -29,6 +30,7 @@ type Publisher interface {
|
||||
}
|
||||
|
||||
var publishers = []Publisher{
|
||||
release.Pipe{},
|
||||
brew.Pipe{},
|
||||
scoop.Pipe{},
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/apex/log"
|
||||
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
"github.com/goreleaser/goreleaser/internal/client"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe"
|
||||
@ -38,16 +37,16 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
// Publish github release
|
||||
func (Pipe) Publish(ctx *context.Context) error {
|
||||
c, err := client.NewGitHub(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return doRun(ctx, c)
|
||||
return doPublish(ctx, c)
|
||||
}
|
||||
|
||||
func doRun(ctx *context.Context, c client.Client) error {
|
||||
func doPublish(ctx *context.Context, c client.Client) error {
|
||||
if ctx.Config.Release.Disable {
|
||||
return pipe.Skip("release pipe is disabled")
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func TestRunPipe(t *testing.T) {
|
||||
Path: debfile.Name(),
|
||||
})
|
||||
client := &DummyClient{}
|
||||
assert.NoError(t, doRun(ctx, client))
|
||||
assert.NoError(t, doPublish(ctx, client))
|
||||
assert.True(t, client.CreatedRelease)
|
||||
assert.True(t, client.UploadedFile)
|
||||
assert.Contains(t, client.UploadedFileNames, "bin.deb")
|
||||
@ -70,7 +70,7 @@ func TestRunPipeReleaseCreationFailed(t *testing.T) {
|
||||
client := &DummyClient{
|
||||
FailToCreateRelease: true,
|
||||
}
|
||||
assert.Error(t, doRun(ctx, client))
|
||||
assert.Error(t, doPublish(ctx, client))
|
||||
assert.False(t, client.CreatedRelease)
|
||||
assert.False(t, client.UploadedFile)
|
||||
}
|
||||
@ -92,7 +92,7 @@ func TestRunPipeWithFileThatDontExist(t *testing.T) {
|
||||
Path: "/nope/nope/nope",
|
||||
})
|
||||
client := &DummyClient{}
|
||||
assert.Error(t, doRun(ctx, client))
|
||||
assert.Error(t, doPublish(ctx, client))
|
||||
assert.True(t, client.CreatedRelease)
|
||||
assert.False(t, client.UploadedFile)
|
||||
}
|
||||
@ -120,7 +120,7 @@ func TestRunPipeUploadFailure(t *testing.T) {
|
||||
client := &DummyClient{
|
||||
FailToUpload: true,
|
||||
}
|
||||
assert.Error(t, doRun(ctx, client))
|
||||
assert.Error(t, doPublish(ctx, client))
|
||||
assert.True(t, client.CreatedRelease)
|
||||
assert.False(t, client.UploadedFile)
|
||||
}
|
||||
@ -131,7 +131,7 @@ func TestSnapshot(t *testing.T) {
|
||||
Parallelism: 1,
|
||||
}
|
||||
client := &DummyClient{}
|
||||
testlib.AssertSkipped(t, doRun(ctx, client))
|
||||
testlib.AssertSkipped(t, doPublish(ctx, client))
|
||||
assert.False(t, client.CreatedRelease)
|
||||
assert.False(t, client.UploadedFile)
|
||||
}
|
||||
@ -143,7 +143,7 @@ func TestPipeDisabled(t *testing.T) {
|
||||
},
|
||||
})
|
||||
client := &DummyClient{}
|
||||
testlib.AssertSkipped(t, doRun(ctx, client))
|
||||
testlib.AssertSkipped(t, doPublish(ctx, client))
|
||||
assert.False(t, client.CreatedRelease)
|
||||
assert.False(t, client.UploadedFile)
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import (
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/nfpm"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/publish"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/put"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/release"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/s3"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/sign"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/snapcraft"
|
||||
@ -53,6 +52,5 @@ var Pipeline = []Piper{
|
||||
artifactory.Pipe{}, // push to artifactory
|
||||
put.Pipe{}, // upload to http server
|
||||
s3.Pipe{}, // push to s3/minio
|
||||
release.Pipe{}, // release to github
|
||||
publish.Pipe{}, // publishes artifacts
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user