-
-
Notifications
You must be signed in to change notification settings - Fork 911
/
client.go
38 lines (33 loc) · 1.05 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package client contains the client implementations for several providers.
package client
import (
"os"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
)
// Info of the repository
type Info struct {
Description string
Homepage string
URL string
}
// Client interface
type Client interface {
CreateRelease(ctx *context.Context, body string) (releaseID string, err error)
CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo config.Repo, content []byte, path, message string) (err error)
Upload(ctx *context.Context, releaseID string, artifact *artifact.Artifact, file *os.File) (err error)
}
// New creates a new client depending on the token type
func New(ctx *context.Context) (Client, error) {
if ctx.TokenType == context.TokenTypeGitHub {
return NewGitHub(ctx)
}
if ctx.TokenType == context.TokenTypeGitLab {
return NewGitLab(ctx)
}
if ctx.TokenType == context.TokenTypeGitea {
return NewGitea(ctx)
}
return nil, nil
}