mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
parent
40ec5ec1f2
commit
9e58a65519
@ -39,18 +39,19 @@ func (r Repo) String() string {
|
||||
|
||||
// Homebrew contains the brew section
|
||||
type Homebrew struct {
|
||||
GitHub Repo `yaml:",omitempty"`
|
||||
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
|
||||
Folder string `yaml:",omitempty"`
|
||||
Caveats string `yaml:",omitempty"`
|
||||
Plist string `yaml:",omitempty"`
|
||||
Install string `yaml:",omitempty"`
|
||||
Dependencies []string `yaml:",omitempty"`
|
||||
Test string `yaml:",omitempty"`
|
||||
Conflicts []string `yaml:",omitempty"`
|
||||
Description string `yaml:",omitempty"`
|
||||
Homepage string `yaml:",omitempty"`
|
||||
SkipUpload bool `yaml:"skip_upload,omitempty"`
|
||||
GitHub Repo `yaml:",omitempty"`
|
||||
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
|
||||
Folder string `yaml:",omitempty"`
|
||||
Caveats string `yaml:",omitempty"`
|
||||
Plist string `yaml:",omitempty"`
|
||||
Install string `yaml:",omitempty"`
|
||||
Dependencies []string `yaml:",omitempty"`
|
||||
Test string `yaml:",omitempty"`
|
||||
Conflicts []string `yaml:",omitempty"`
|
||||
Description string `yaml:",omitempty"`
|
||||
Homepage string `yaml:",omitempty"`
|
||||
SkipUpload bool `yaml:"skip_upload,omitempty"`
|
||||
DownloadStrategy string `yaml:"download_strategy,omitempty"`
|
||||
|
||||
// Capture all undefined fields and should be empty after loading
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
|
@ -162,22 +162,24 @@ func dataFor(ctx *context.Context, client client.Client, artifact artifact.Artif
|
||||
if ctx.Config.GitHubURLs.Download != "" {
|
||||
url = ctx.Config.GitHubURLs.Download
|
||||
}
|
||||
var cfg = ctx.Config.Brew
|
||||
return templateData{
|
||||
Name: formulaNameFor(ctx.Config.ProjectName),
|
||||
DownloadURL: url,
|
||||
Desc: ctx.Config.Brew.Description,
|
||||
Homepage: ctx.Config.Brew.Homepage,
|
||||
Repo: ctx.Config.Release.GitHub,
|
||||
Tag: ctx.Git.CurrentTag,
|
||||
Version: ctx.Version,
|
||||
Caveats: ctx.Config.Brew.Caveats,
|
||||
File: artifact.Name,
|
||||
SHA256: sum,
|
||||
Dependencies: ctx.Config.Brew.Dependencies,
|
||||
Conflicts: ctx.Config.Brew.Conflicts,
|
||||
Plist: ctx.Config.Brew.Plist,
|
||||
Install: split(ctx.Config.Brew.Install),
|
||||
Tests: split(ctx.Config.Brew.Test),
|
||||
Name: formulaNameFor(ctx.Config.ProjectName),
|
||||
DownloadURL: url,
|
||||
Desc: cfg.Description,
|
||||
Homepage: cfg.Homepage,
|
||||
Repo: ctx.Config.Release.GitHub,
|
||||
Tag: ctx.Git.CurrentTag,
|
||||
Version: ctx.Version,
|
||||
Caveats: cfg.Caveats,
|
||||
File: artifact.Name,
|
||||
SHA256: sum,
|
||||
Dependencies: cfg.Dependencies,
|
||||
Conflicts: cfg.Conflicts,
|
||||
Plist: cfg.Plist,
|
||||
Install: split(cfg.Install),
|
||||
Tests: split(cfg.Test),
|
||||
DownloadStrategy: cfg.DownloadStrategy,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -179,6 +179,23 @@ func TestRunPipe(t *testing.T) {
|
||||
assert.NoError(tt, err)
|
||||
assert.Equal(tt, string(bts), string(distBts))
|
||||
})
|
||||
|
||||
t.Run("custom download strategy", func(tt *testing.T) {
|
||||
ctx.Config.Brew.DownloadStrategy = "GitHubPrivateRepositoryReleaseDownloadStrategy"
|
||||
assert.NoError(tt, doRun(ctx, client))
|
||||
assert.True(tt, client.CreatedFile)
|
||||
var golden = "testdata/run_pipe_download_strategy.rb.golden"
|
||||
if *update {
|
||||
ioutil.WriteFile(golden, []byte(client.Content), 0655)
|
||||
}
|
||||
bts, err := ioutil.ReadFile(golden)
|
||||
assert.NoError(tt, err)
|
||||
assert.Equal(tt, string(bts), client.Content)
|
||||
|
||||
distBts, err := ioutil.ReadFile(distFile)
|
||||
assert.NoError(tt, err)
|
||||
assert.Equal(tt, string(bts), string(distBts))
|
||||
})
|
||||
}
|
||||
|
||||
func TestRunPipeNoDarwin64Build(t *testing.T) {
|
||||
|
@ -3,27 +3,29 @@ package brew
|
||||
import "github.com/goreleaser/goreleaser/config"
|
||||
|
||||
type templateData struct {
|
||||
Name string
|
||||
Desc string
|
||||
Homepage string
|
||||
DownloadURL string
|
||||
Repo config.Repo // FIXME: will not work for anything but github right now.
|
||||
Tag string
|
||||
Version string
|
||||
Caveats string
|
||||
File string
|
||||
SHA256 string
|
||||
Plist string
|
||||
Install []string
|
||||
Dependencies []string
|
||||
Conflicts []string
|
||||
Tests []string
|
||||
Name string
|
||||
Desc string
|
||||
Homepage string
|
||||
DownloadURL string
|
||||
Repo config.Repo // FIXME: will not work for anything but github right now.
|
||||
Tag string
|
||||
Version string
|
||||
Caveats string
|
||||
File string
|
||||
SHA256 string
|
||||
Plist string
|
||||
DownloadStrategy string
|
||||
Install []string
|
||||
Dependencies []string
|
||||
Conflicts []string
|
||||
Tests []string
|
||||
}
|
||||
|
||||
const formulaTemplate = `class {{ .Name }} < Formula
|
||||
desc "{{ .Desc }}"
|
||||
homepage "{{ .Homepage }}"
|
||||
url "{{ .DownloadURL }}/{{ .Repo.Owner }}/{{ .Repo.Name }}/releases/download/{{ .Tag }}/{{ .File }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
version "{{ .Version }}"
|
||||
sha256 "{{ .SHA256 }}"
|
||||
|
||||
|
33
pipeline/brew/testdata/run_pipe_download_strategy.rb.golden
vendored
Normal file
33
pipeline/brew/testdata/run_pipe_download_strategy.rb.golden
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
class RunPipe < Formula
|
||||
desc "A run pipe test formula"
|
||||
homepage "https://github.com/goreleaser"
|
||||
url "http://github.example.org/test/test/releases/download/v1.0.1/bin.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
|
||||
version "1.0.1"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
|
||||
depends_on "zsh"
|
||||
depends_on "bash"
|
||||
|
||||
conflicts_with "gtk+"
|
||||
conflicts_with "qt"
|
||||
|
||||
def install
|
||||
bin.install "foo"
|
||||
end
|
||||
|
||||
def caveats
|
||||
"don't do this"
|
||||
end
|
||||
|
||||
plist_options :startup => false
|
||||
|
||||
def plist; <<-EOS.undent
|
||||
<xml>whatever</xml>
|
||||
EOS
|
||||
end
|
||||
|
||||
test do
|
||||
system "true"
|
||||
system "#{bin}/foo -h"
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user