mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
fixed uploads url
This commit is contained in:
parent
cff77260cc
commit
618711cd43
@ -15,9 +15,10 @@ import (
|
||||
|
||||
// Repo represents any kind of repo (github, gitlab, etc)
|
||||
type Repo struct {
|
||||
Owner string `yaml:",omitempty"`
|
||||
Name string `yaml:",omitempty"`
|
||||
URL string `yaml:",omitempty"`
|
||||
Owner string `yaml:",omitempty"`
|
||||
Name string `yaml:",omitempty"`
|
||||
APIURL string `yaml:api_url",omitempty"`
|
||||
UploadsURL string `yaml:uploads_url",omitempty"`
|
||||
|
||||
// Capture all undefined fields and should be empty after loading
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/google/go-github/github"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
@ -17,23 +16,26 @@ type githubClient struct {
|
||||
}
|
||||
|
||||
// NewGitHub returns a github client implementation
|
||||
func NewGitHub(ctx *context.Context, repo config.Repo) Client {
|
||||
func NewGitHub(ctx *context.Context, api, upload string) (Client, error) {
|
||||
ts := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: ctx.Token},
|
||||
)
|
||||
client := github.NewClient(oauth2.NewClient(ctx, ts))
|
||||
if repo.URL != "" {
|
||||
url, err := url.Parse(repo.URL)
|
||||
if api != "" {
|
||||
apiURL, err := url.Parse(api)
|
||||
if err != nil {
|
||||
// TODO: return the err here
|
||||
log.Fatal("failed to parse url")
|
||||
return &githubClient{}, err
|
||||
}
|
||||
// TODO: check if we need to change upload url as well
|
||||
client.BaseURL = url
|
||||
client.BaseURL = apiURL
|
||||
}
|
||||
return &githubClient{
|
||||
client: client,
|
||||
if upload != "" {
|
||||
uploadURL, err := url.Parse(upload)
|
||||
if err != nil {
|
||||
return &githubClient{}, err
|
||||
}
|
||||
client.UploadURL = uploadURL
|
||||
}
|
||||
return &githubClient{client}, nil
|
||||
}
|
||||
|
||||
func (c *githubClient) CreateFile(
|
||||
|
@ -33,7 +33,11 @@ func (Pipe) Description() string {
|
||||
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
return doRun(ctx, client.NewGitHub(ctx, ctx.Config.Brew.GitHub))
|
||||
client, err := client.NewGitHub(ctx, ctx.Config.Brew.GitHub.APIURL, ctx.Config.Brew.GitHub.UploadsURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return doRun(ctx, client)
|
||||
}
|
||||
|
||||
func doRun(ctx *context.Context, client client.Client) error {
|
||||
|
@ -23,7 +23,11 @@ func (Pipe) Description() string {
|
||||
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
return doRun(ctx, client.NewGitHub(ctx, ctx.Config.Release.GitHub))
|
||||
client, err := client.NewGitHub(ctx, ctx.Config.Release.GitHub.APIURL, ctx.Config.Release.GitHub.UploadsURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return doRun(ctx, client)
|
||||
}
|
||||
|
||||
func doRun(ctx *context.Context, client client.Client) error {
|
||||
|
Loading…
Reference in New Issue
Block a user