1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-25 21:29:14 +02:00

support github enterprise

This commit is contained in:
Carlos Alexandro Becker 2017-09-15 11:04:03 -03:00
parent ab1acbb897
commit 567b7a9b1b
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 19 additions and 6 deletions

View File

@ -17,6 +17,7 @@ import (
type Repo struct {
Owner string `yaml:",omitempty"`
Name string `yaml:",omitempty"`
URL string `yaml:",omitempty"`
// Capture all undefined fields and should be empty after loading
XXX map[string]interface{} `yaml:",inline"`
@ -101,8 +102,9 @@ type Archive struct {
// Release config used for the GitHub release
type Release struct {
GitHub Repo `yaml:",omitempty"`
Draft bool `yaml:",omitempty"`
GitHub Repo `yaml:",omitempty"`
Draft bool `yaml:",omitempty"`
GitHubURL string `yaml:"github_url,omitempty"`
// Capture all undefined fields and should be empty after loading
XXX map[string]interface{} `yaml:",inline"`

View File

@ -2,10 +2,12 @@ package client
import (
"bytes"
"net/url"
"os"
"github.com/apex/log"
"github.com/google/go-github/github"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"golang.org/x/oauth2"
)
@ -15,12 +17,21 @@ type githubClient struct {
}
// NewGitHub returns a github client implementation
func NewGitHub(ctx *context.Context) Client {
func NewGitHub(ctx *context.Context, repo config.Repo) Client {
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 err != nil {
// TODO: return the err here
log.Fatal("failed to parse url")
}
client.BaseURL = url
}
return &githubClient{
client: github.NewClient(oauth2.NewClient(ctx, ts)),
client: client,
}
}

View File

@ -33,7 +33,7 @@ func (Pipe) Description() string {
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
return doRun(ctx, client.NewGitHub(ctx))
return doRun(ctx, client.NewGitHub(ctx, ctx.Config.Brew.GitHub))
}
func doRun(ctx *context.Context, client client.Client) error {

View File

@ -23,7 +23,7 @@ func (Pipe) Description() string {
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
return doRun(ctx, client.NewGitHub(ctx))
return doRun(ctx, client.NewGitHub(ctx, ctx.Config.Release.GitHub))
}
func doRun(ctx *context.Context, client client.Client) error {