You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-05 00:59:04 +02:00
feat: support custom tokens in Homebrew & Scoop (#1650)
This commit is contained in:
@ -18,11 +18,23 @@ type Info struct {
|
||||
URL string
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
Owner string
|
||||
Name string
|
||||
}
|
||||
|
||||
func (r Repo) String() string {
|
||||
if r.Owner == "" && r.Name == "" {
|
||||
return ""
|
||||
}
|
||||
return r.Owner + "/" + r.Name
|
||||
}
|
||||
|
||||
// Client interface.
|
||||
type Client interface {
|
||||
CreateRelease(ctx *context.Context, body string) (releaseID string, err error)
|
||||
ReleaseURLTemplate(ctx *context.Context) (string, error)
|
||||
CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo config.Repo, content []byte, path, message string) (err error)
|
||||
CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo Repo, content []byte, path, message string) (err error)
|
||||
Upload(ctx *context.Context, releaseID string, artifact *artifact.Artifact, file *os.File) (err error)
|
||||
}
|
||||
|
||||
@ -30,13 +42,26 @@ type Client interface {
|
||||
func New(ctx *context.Context) (Client, error) {
|
||||
log.WithField("type", ctx.TokenType).Info("token type")
|
||||
if ctx.TokenType == context.TokenTypeGitHub {
|
||||
return NewGitHub(ctx)
|
||||
return NewGitHub(ctx, ctx.Token)
|
||||
}
|
||||
if ctx.TokenType == context.TokenTypeGitLab {
|
||||
return NewGitLab(ctx)
|
||||
return NewGitLab(ctx, ctx.Token)
|
||||
}
|
||||
if ctx.TokenType == context.TokenTypeGitea {
|
||||
return NewGitea(ctx)
|
||||
return NewGitea(ctx, ctx.Token)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewWithToken(ctx *context.Context, token string) (Client, error) {
|
||||
if ctx.TokenType == context.TokenTypeGitHub {
|
||||
return NewGitHub(ctx, token)
|
||||
}
|
||||
if ctx.TokenType == context.TokenTypeGitLab {
|
||||
return NewGitLab(ctx, token)
|
||||
}
|
||||
if ctx.TokenType == context.TokenTypeGitea {
|
||||
return NewGitea(ctx, token)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user