mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-29 21:47:01 +02:00
support github enterprise
This commit is contained in:
parent
ab1acbb897
commit
567b7a9b1b
@ -17,6 +17,7 @@ import (
|
|||||||
type Repo struct {
|
type Repo struct {
|
||||||
Owner string `yaml:",omitempty"`
|
Owner string `yaml:",omitempty"`
|
||||||
Name string `yaml:",omitempty"`
|
Name string `yaml:",omitempty"`
|
||||||
|
URL string `yaml:",omitempty"`
|
||||||
|
|
||||||
// Capture all undefined fields and should be empty after loading
|
// Capture all undefined fields and should be empty after loading
|
||||||
XXX map[string]interface{} `yaml:",inline"`
|
XXX map[string]interface{} `yaml:",inline"`
|
||||||
@ -101,8 +102,9 @@ type Archive struct {
|
|||||||
|
|
||||||
// Release config used for the GitHub release
|
// Release config used for the GitHub release
|
||||||
type Release struct {
|
type Release struct {
|
||||||
GitHub Repo `yaml:",omitempty"`
|
GitHub Repo `yaml:",omitempty"`
|
||||||
Draft bool `yaml:",omitempty"`
|
Draft bool `yaml:",omitempty"`
|
||||||
|
GitHubURL string `yaml:"github_url,omitempty"`
|
||||||
|
|
||||||
// Capture all undefined fields and should be empty after loading
|
// Capture all undefined fields and should be empty after loading
|
||||||
XXX map[string]interface{} `yaml:",inline"`
|
XXX map[string]interface{} `yaml:",inline"`
|
||||||
|
@ -2,10 +2,12 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
"github.com/goreleaser/goreleaser/config"
|
||||||
"github.com/goreleaser/goreleaser/context"
|
"github.com/goreleaser/goreleaser/context"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
@ -15,12 +17,21 @@ type githubClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGitHub returns a github client implementation
|
// NewGitHub returns a github client implementation
|
||||||
func NewGitHub(ctx *context.Context) Client {
|
func NewGitHub(ctx *context.Context, repo config.Repo) Client {
|
||||||
ts := oauth2.StaticTokenSource(
|
ts := oauth2.StaticTokenSource(
|
||||||
&oauth2.Token{AccessToken: ctx.Token},
|
&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{
|
return &githubClient{
|
||||||
client: github.NewClient(oauth2.NewClient(ctx, ts)),
|
client: client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ func (Pipe) Description() string {
|
|||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
func (Pipe) Run(ctx *context.Context) error {
|
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 {
|
func doRun(ctx *context.Context, client client.Client) error {
|
||||||
|
@ -23,7 +23,7 @@ func (Pipe) Description() string {
|
|||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
func (Pipe) Run(ctx *context.Context) error {
|
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 {
|
func doRun(ctx *context.Context, client client.Client) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user