You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-13 01:30:50 +02:00
github enterprise config update
This commit is contained in:
@ -13,13 +13,17 @@ import (
|
|||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GitHubURLs holds the URLs to be used when using github enterprise
|
||||||
|
type GitHubURLs struct {
|
||||||
|
API string `yaml:"api,omitempty"`
|
||||||
|
Upload string `yaml:"upload,omitempty"`
|
||||||
|
Download string `yaml:"download,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Repo represents any kind of repo (github, gitlab, etc)
|
// Repo represents any kind of repo (github, gitlab, etc)
|
||||||
type Repo struct {
|
type Repo struct {
|
||||||
Owner string `yaml:",omitempty"`
|
Owner string `yaml:",omitempty"`
|
||||||
Name string `yaml:",omitempty"`
|
Name string `yaml:",omitempty"`
|
||||||
APIURL string `yaml:"api_url,omitempty"`
|
|
||||||
UploadsURL string `yaml:"uploads_url,omitempty"`
|
|
||||||
DownloadsURL string `yaml:"downloads_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"`
|
||||||
@ -193,6 +197,9 @@ type Project struct {
|
|||||||
// this is a hack ¯\_(ツ)_/¯
|
// this is a hack ¯\_(ツ)_/¯
|
||||||
SingleBuild Build `yaml:"build,omitempty"`
|
SingleBuild Build `yaml:"build,omitempty"`
|
||||||
|
|
||||||
|
// should be set if using github enterprise
|
||||||
|
GitHubURLs GitHubURLs `yaml:"github_urls,omitempty"`
|
||||||
|
|
||||||
// test only property indicating the path to the dist folder
|
// test only property indicating the path to the dist folder
|
||||||
Dist string `yaml:"-"`
|
Dist string `yaml:"-"`
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -17,24 +16,22 @@ type githubClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGitHub returns a github client implementation
|
// NewGitHub returns a github client implementation
|
||||||
func NewGitHub(ctx *context.Context, repo config.Repo) (Client, error) {
|
func NewGitHub(ctx *context.Context) (Client, error) {
|
||||||
ts := oauth2.StaticTokenSource(
|
ts := oauth2.StaticTokenSource(
|
||||||
&oauth2.Token{AccessToken: ctx.Token},
|
&oauth2.Token{AccessToken: ctx.Token},
|
||||||
)
|
)
|
||||||
client := github.NewClient(oauth2.NewClient(ctx, ts))
|
client := github.NewClient(oauth2.NewClient(ctx, ts))
|
||||||
if repo.APIURL != "" {
|
if ctx.Config.GitHubURLs.API != "" {
|
||||||
url, err := url.Parse(repo.APIURL)
|
api, err := url.Parse(ctx.Config.GitHubURLs.API)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &githubClient{}, err
|
return &githubClient{}, err
|
||||||
}
|
}
|
||||||
client.BaseURL = url
|
upload, err := url.Parse(ctx.Config.GitHubURLs.Upload)
|
||||||
}
|
|
||||||
if repo.UploadsURL != "" {
|
|
||||||
url, err := url.Parse(repo.UploadsURL)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &githubClient{}, err
|
return &githubClient{}, err
|
||||||
}
|
}
|
||||||
client.UploadURL = url
|
client.BaseURL = api
|
||||||
|
client.UploadURL = upload
|
||||||
}
|
}
|
||||||
|
|
||||||
return &githubClient{client}, nil
|
return &githubClient{client}, nil
|
||||||
|
@ -97,8 +97,13 @@ func dataFor(ctx *context.Context, client client.Client, folder string) (result
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var url = "https://github.com"
|
||||||
|
if ctx.Config.GitHubURLs.Download != "" {
|
||||||
|
url = ctx.Config.GitHubURLs.Download
|
||||||
|
}
|
||||||
return templateData{
|
return templateData{
|
||||||
Name: formulaNameFor(ctx.Config.ProjectName),
|
Name: formulaNameFor(ctx.Config.ProjectName),
|
||||||
|
DownloadURL: url,
|
||||||
Desc: ctx.Config.Brew.Description,
|
Desc: ctx.Config.Brew.Description,
|
||||||
Homepage: ctx.Config.Brew.Homepage,
|
Homepage: ctx.Config.Brew.Homepage,
|
||||||
Repo: ctx.Config.Release.GitHub,
|
Repo: ctx.Config.Release.GitHub,
|
||||||
|
@ -6,6 +6,7 @@ type templateData struct {
|
|||||||
Name string
|
Name string
|
||||||
Desc string
|
Desc string
|
||||||
Homepage string
|
Homepage string
|
||||||
|
DownloadURL string
|
||||||
Repo config.Repo // FIXME: will not work for anything but github right now.
|
Repo config.Repo // FIXME: will not work for anything but github right now.
|
||||||
Tag string
|
Tag string
|
||||||
Version string
|
Version string
|
||||||
@ -22,11 +23,7 @@ type templateData struct {
|
|||||||
const formulaTemplate = `class {{ .Name }} < Formula
|
const formulaTemplate = `class {{ .Name }} < Formula
|
||||||
desc "{{ .Desc }}"
|
desc "{{ .Desc }}"
|
||||||
homepage "{{ .Homepage }}"
|
homepage "{{ .Homepage }}"
|
||||||
{{ if .Repo.DownloadsURL }}
|
url "{{ .DownloadsURL }}/{{ .Repo.Owner }}/{{ .Repo.Name }}/releases/download/{{ .Tag }}/{{ .File }}"
|
||||||
url "{{ .Repo.DownloadsURL }}{{ .Repo.Owner }}/{{ .Repo.Name }}/releases/download/{{ .Tag }}/{{ .File }}"
|
|
||||||
{{- else -}}
|
|
||||||
url "https://github.com/{{ .Repo.Owner }}/{{ .Repo.Name }}/releases/download/{{ .Tag }}/{{ .File }}"
|
|
||||||
{{ end -}}
|
|
||||||
|
|
||||||
version "{{ .Version }}"
|
version "{{ .Version }}"
|
||||||
sha256 "{{ .SHA256 }}"
|
sha256 "{{ .SHA256 }}"
|
||||||
|
Reference in New Issue
Block a user