You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-15 01:34:21 +02:00
Merge branch 'master' into dep
This commit is contained in:
@ -2,7 +2,7 @@ language: go
|
|||||||
go: 1.8
|
go: 1.8
|
||||||
install: make setup
|
install: make setup
|
||||||
script:
|
script:
|
||||||
- make ci
|
- make test
|
||||||
after_success:
|
after_success:
|
||||||
- go get github.com/mattn/goveralls
|
- go get github.com/mattn/goveralls
|
||||||
- goveralls -coverprofile=coverage.out -service=travis-ci -repotoken="$COVERALLS_TOKEN"
|
- goveralls -coverprofile=coverage.out -service=travis-ci -repotoken="$COVERALLS_TOKEN"
|
||||||
|
2
Makefile
2
Makefile
@ -29,7 +29,7 @@ lint: ## Run all the linters
|
|||||||
--enable=errcheck \
|
--enable=errcheck \
|
||||||
--enable=vet \
|
--enable=vet \
|
||||||
--enable=vetshadow \
|
--enable=vetshadow \
|
||||||
--deadline=1m \
|
--deadline=10m \
|
||||||
./...
|
./...
|
||||||
|
|
||||||
ci: lint test ## Run all the tests and code checks
|
ci: lint test ## Run all the tests and code checks
|
||||||
|
@ -280,9 +280,14 @@ brew:
|
|||||||
- bash
|
- bash
|
||||||
|
|
||||||
# Packages that run as a service
|
# Packages that run as a service
|
||||||
plist:
|
plist:|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
...
|
...
|
||||||
|
|
||||||
|
# Custom install script for brew. Default: "bin.install "program"
|
||||||
|
install:|
|
||||||
|
bin.install "program"
|
||||||
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
By defining the `brew` section, GoReleaser will take care of publishing the Homebrew tap.
|
By defining the `brew` section, GoReleaser will take care of publishing the Homebrew tap.
|
||||||
|
@ -12,6 +12,7 @@ type Homebrew struct {
|
|||||||
Folder string
|
Folder string
|
||||||
Caveats string
|
Caveats string
|
||||||
Plist string
|
Plist string
|
||||||
|
Install string
|
||||||
Dependencies []string
|
Dependencies []string
|
||||||
Conflicts []string
|
Conflicts []string
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,9 @@ const formula = `class {{ .Name }} < Formula
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
def install
|
def install
|
||||||
bin.install "{{ .BinaryName }}"
|
{{- range $index, $element := .Install }}
|
||||||
|
{{ . -}}
|
||||||
|
{{- end }}
|
||||||
end
|
end
|
||||||
|
|
||||||
{{- if .Caveats }}
|
{{- if .Caveats }}
|
||||||
@ -71,6 +73,7 @@ type templateData struct {
|
|||||||
Format string
|
Format string
|
||||||
SHA256 string
|
SHA256 string
|
||||||
Plist string
|
Plist string
|
||||||
|
Install []string
|
||||||
Dependencies []string
|
Dependencies []string
|
||||||
Conflicts []string
|
Conflicts []string
|
||||||
}
|
}
|
||||||
@ -188,6 +191,7 @@ func dataFor(
|
|||||||
Dependencies: ctx.Config.Brew.Dependencies,
|
Dependencies: ctx.Config.Brew.Dependencies,
|
||||||
Conflicts: ctx.Config.Brew.Conflicts,
|
Conflicts: ctx.Config.Brew.Conflicts,
|
||||||
Plist: ctx.Config.Brew.Plist,
|
Plist: ctx.Config.Brew.Plist,
|
||||||
|
Install: strings.Split(ctx.Config.Brew.Install, "\n"),
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ var defaultTemplateData = templateData{
|
|||||||
File: "test_Darwin_x86_64",
|
File: "test_Darwin_x86_64",
|
||||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
||||||
Format: "tar.gz",
|
Format: "tar.gz",
|
||||||
Plist: "it works",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertDefaultTemplateData(t *testing.T, formulae string) {
|
func assertDefaultTemplateData(t *testing.T, formulae string) {
|
||||||
@ -39,7 +38,6 @@ func assertDefaultTemplateData(t *testing.T, formulae string) {
|
|||||||
assert.Contains(formulae, "url \"https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz\"")
|
assert.Contains(formulae, "url \"https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz\"")
|
||||||
assert.Contains(formulae, "sha256 \"1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68\"")
|
assert.Contains(formulae, "sha256 \"1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68\"")
|
||||||
assert.Contains(formulae, "version \"0.1.3\"")
|
assert.Contains(formulae, "version \"0.1.3\"")
|
||||||
assert.Contains(formulae, "bin.install \"test\"")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFullFormulae(t *testing.T) {
|
func TestFullFormulae(t *testing.T) {
|
||||||
@ -48,6 +46,8 @@ func TestFullFormulae(t *testing.T) {
|
|||||||
data.Caveats = "Here are some caveats"
|
data.Caveats = "Here are some caveats"
|
||||||
data.Dependencies = []string{"gtk", "git"}
|
data.Dependencies = []string{"gtk", "git"}
|
||||||
data.Conflicts = []string{"conflicting_dep"}
|
data.Conflicts = []string{"conflicting_dep"}
|
||||||
|
data.Plist = "it works"
|
||||||
|
data.Install = []string{"custom install script", "another install script"}
|
||||||
out, err := doBuildFormula(data)
|
out, err := doBuildFormula(data)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
formulae := out.String()
|
formulae := out.String()
|
||||||
@ -57,6 +57,8 @@ func TestFullFormulae(t *testing.T) {
|
|||||||
assert.Contains(formulae, "depends_on \"gtk\"")
|
assert.Contains(formulae, "depends_on \"gtk\"")
|
||||||
assert.Contains(formulae, "depends_on \"git\"")
|
assert.Contains(formulae, "depends_on \"git\"")
|
||||||
assert.Contains(formulae, "conflicts_with \"conflicting_dep\"")
|
assert.Contains(formulae, "conflicts_with \"conflicting_dep\"")
|
||||||
|
assert.Contains(formulae, "custom install script")
|
||||||
|
assert.Contains(formulae, "another install script")
|
||||||
assert.Contains(formulae, "def plist;")
|
assert.Contains(formulae, "def plist;")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,4 +70,5 @@ func TestFormulaeSimple(t *testing.T) {
|
|||||||
assertDefaultTemplateData(t, formulae)
|
assertDefaultTemplateData(t, formulae)
|
||||||
assert.NotContains(formulae, "def caveats")
|
assert.NotContains(formulae, "def caveats")
|
||||||
assert.NotContains(formulae, "depends_on")
|
assert.NotContains(formulae, "depends_on")
|
||||||
|
assert.NotContains(formulae, "def plist;")
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
for _, goarch := range ctx.Config.Build.Goarch {
|
for _, goarch := range ctx.Config.Build.Goarch {
|
||||||
goos := goos
|
goos := goos
|
||||||
goarch := goarch
|
goarch := goarch
|
||||||
|
if !valid(goos, goarch) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
name, err := nameFor(ctx, goos, goarch)
|
name, err := nameFor(ctx, goos, goarch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -75,3 +78,47 @@ func run(goos, goarch string, command []string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// list from https://golang.org/doc/install/source#environment
|
||||||
|
var valids = []string{
|
||||||
|
"androidarm",
|
||||||
|
"darwin386",
|
||||||
|
"darwinamd64",
|
||||||
|
"darwinarm",
|
||||||
|
"darwinarm64",
|
||||||
|
"dragonflyamd64",
|
||||||
|
"freebsd386",
|
||||||
|
"freebsdamd64",
|
||||||
|
"freebsdarm",
|
||||||
|
"linux386",
|
||||||
|
"linuxamd64",
|
||||||
|
"linuxarm",
|
||||||
|
"linuxarm64",
|
||||||
|
"linuxppc64",
|
||||||
|
"linuxppc64le",
|
||||||
|
"linuxmips",
|
||||||
|
"linuxmipsle",
|
||||||
|
"linuxmips64",
|
||||||
|
"linuxmips64le",
|
||||||
|
"netbsd386",
|
||||||
|
"netbsdamd64",
|
||||||
|
"netbsdarm",
|
||||||
|
"openbsd386",
|
||||||
|
"openbsdamd64",
|
||||||
|
"openbsdarm",
|
||||||
|
"plan9386",
|
||||||
|
"plan9amd64",
|
||||||
|
"solarisamd64",
|
||||||
|
"windows386",
|
||||||
|
"windowsamd64",
|
||||||
|
}
|
||||||
|
|
||||||
|
func valid(goos, goarch string) bool {
|
||||||
|
var s = goos + goarch
|
||||||
|
for _, a := range valids {
|
||||||
|
if a == s {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
13
pipeline/build/build_test.go
Normal file
13
pipeline/build/build_test.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValid(t *testing.T) {
|
||||||
|
assert.True(t, valid("windows", "386"))
|
||||||
|
assert.True(t, valid("linux", "386"))
|
||||||
|
assert.False(t, valid("windows", "arm"))
|
||||||
|
}
|
@ -69,6 +69,9 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
}
|
}
|
||||||
ctx.Config.Archive.Files = files
|
ctx.Config.Archive.Files = files
|
||||||
}
|
}
|
||||||
|
if ctx.Config.Brew.Install == "" {
|
||||||
|
ctx.Config.Brew.Install = "bin.install \"" + ctx.Config.Build.BinaryName + "\""
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ func TestFillBasicData(t *testing.T) {
|
|||||||
assert.Contains(ctx.Config.Build.Goos, "linux")
|
assert.Contains(ctx.Config.Build.Goos, "linux")
|
||||||
assert.Contains(ctx.Config.Build.Goarch, "386")
|
assert.Contains(ctx.Config.Build.Goarch, "386")
|
||||||
assert.Contains(ctx.Config.Build.Goarch, "amd64")
|
assert.Contains(ctx.Config.Build.Goarch, "amd64")
|
||||||
|
assert.Contains(ctx.Config.Brew.Install, "bin.install \"goreleaser\"")
|
||||||
assert.NotEmpty(
|
assert.NotEmpty(
|
||||||
ctx.Config.Archive.Replacements,
|
ctx.Config.Archive.Replacements,
|
||||||
ctx.Config.Archive.NameTemplate,
|
ctx.Config.Archive.NameTemplate,
|
||||||
|
Reference in New Issue
Block a user