mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
feat: improved release notes
- Added homebrew taps - Docker pull commands instead of list of docker imgs
This commit is contained in:
parent
0efbe336e3
commit
e87ab21a0a
@ -38,6 +38,7 @@ type Context struct {
|
||||
Binaries map[string]map[string][]Binary
|
||||
Artifacts []string
|
||||
Dockers []string
|
||||
Brews []string
|
||||
ReleaseNotes string
|
||||
Version string
|
||||
Validate bool
|
||||
@ -48,9 +49,12 @@ type Context struct {
|
||||
Parallelism int
|
||||
}
|
||||
|
||||
var artifactsLock sync.Mutex
|
||||
var dockersLock sync.Mutex
|
||||
var binariesLock sync.Mutex
|
||||
var (
|
||||
artifactsLock sync.Mutex
|
||||
dockersLock sync.Mutex
|
||||
binariesLock sync.Mutex
|
||||
brewsLock sync.Mutex
|
||||
)
|
||||
|
||||
// AddArtifact adds a file to upload list
|
||||
func (ctx *Context) AddArtifact(file string) {
|
||||
@ -61,6 +65,14 @@ func (ctx *Context) AddArtifact(file string) {
|
||||
log.WithField("artifact", file).Info("new release artifact")
|
||||
}
|
||||
|
||||
// AddBrew adds a brew tap to the brews list
|
||||
func (ctx *Context) AddBrew(tap string) {
|
||||
brewsLock.Lock()
|
||||
defer brewsLock.Unlock()
|
||||
ctx.Brews = append(ctx.Brews, tap)
|
||||
log.WithField("tap", tap).Info("new brew tap")
|
||||
}
|
||||
|
||||
// AddDocker adds a docker image to the docker images list
|
||||
func (ctx *Context) AddDocker(image string) {
|
||||
dockersLock.Lock()
|
||||
|
@ -20,6 +20,10 @@ func TestMultipleAdds(t *testing.T) {
|
||||
"c/d:2.0.0",
|
||||
"e/f:3.0.0",
|
||||
}
|
||||
var brews = []string{
|
||||
"foo/tap/foo",
|
||||
"bar/bar/bar",
|
||||
}
|
||||
var ctx = New(config.Project{
|
||||
Dist: "dist",
|
||||
})
|
||||
@ -40,10 +44,20 @@ func TestMultipleAdds(t *testing.T) {
|
||||
})
|
||||
}
|
||||
assert.NoError(t, g.Wait())
|
||||
for _, b := range brews {
|
||||
b := b
|
||||
g.Go(func() error {
|
||||
ctx.AddBrew(b)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
assert.NoError(t, g.Wait())
|
||||
assert.Len(t, ctx.Artifacts, len(artifacts))
|
||||
assert.Contains(t, ctx.Artifacts, "a", "b", "c", "d")
|
||||
assert.Len(t, ctx.Dockers, len(dockerfiles))
|
||||
assert.Contains(t, ctx.Dockers, "a/b:1.0.0", "c/d:2.0.0", "e/f:3.0.0")
|
||||
assert.Len(t, ctx.Brews, len(brews))
|
||||
assert.Contains(t, ctx.Brews, "foo/tap/foo", "bar/bar/bar")
|
||||
}
|
||||
|
||||
func TestMultipleBinaryAdds(t *testing.T) {
|
||||
|
@ -115,9 +115,21 @@ func doRun(ctx *context.Context, client client.Client) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.AddBrew(brewTapPath(ctx))
|
||||
return client.CreateFile(ctx, content, path)
|
||||
}
|
||||
|
||||
func brewTapPath(ctx *context.Context) string {
|
||||
return strings.Join(
|
||||
[]string{
|
||||
ctx.Config.Brew.GitHub.Owner,
|
||||
strings.TrimPrefix(ctx.Config.Brew.GitHub.Name, "homebrew-"),
|
||||
ctx.Config.ProjectName,
|
||||
},
|
||||
"/",
|
||||
)
|
||||
}
|
||||
|
||||
func buildFormula(ctx *context.Context, client client.Client, folder string) (bytes.Buffer, error) {
|
||||
data, err := dataFor(ctx, client, folder)
|
||||
if err != nil {
|
||||
|
@ -139,6 +139,8 @@ func TestRunPipe(t *testing.T) {
|
||||
// ioutil.WriteFile("testdata/run_pipe.rb", []byte(client.Content), 0644)
|
||||
|
||||
assert.Equal(t, string(bts), client.Content)
|
||||
|
||||
assert.Equal(t, "test/test/run-pipe", ctx.Brews[0])
|
||||
}
|
||||
|
||||
func TestRunPipeFormatOverride(t *testing.T) {
|
||||
@ -302,6 +304,20 @@ func TestDefault(t *testing.T) {
|
||||
assert.Equal(t, `bin.install "foo"`, ctx.Config.Brew.Install)
|
||||
}
|
||||
|
||||
func TestBrewTapPath(t *testing.T) {
|
||||
assert.Equal(t, "goreleaser/tap/goreleaser", brewTapPath(&context.Context{
|
||||
Config: config.Project{
|
||||
ProjectName: "goreleaser",
|
||||
Brew: config.Homebrew{
|
||||
GitHub: config.Repo{
|
||||
Owner: "goreleaser",
|
||||
Name: "homebrew-tap",
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
CreatedFile bool
|
||||
Content string
|
||||
|
@ -12,10 +12,18 @@ const bodyTemplate = `{{ .ReleaseNotes }}
|
||||
|
||||
{{- if .DockerImages }}
|
||||
|
||||
Docker images:
|
||||
## Docker images
|
||||
{{ range $element := .DockerImages }}
|
||||
- {{ . -}}
|
||||
{{ end -}}
|
||||
- ` + "`docker pull {{ . -}}`" + `
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- if .Brews }}
|
||||
|
||||
## Homebrew taps
|
||||
{{ range $element := .Brews }}
|
||||
- ` + "`brew install {{ . -}}`" + `
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
---
|
||||
@ -37,10 +45,12 @@ func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, er
|
||||
err := template.Execute(&out, struct {
|
||||
ReleaseNotes, GoVersion string
|
||||
DockerImages []string
|
||||
Brews []string
|
||||
}{
|
||||
ReleaseNotes: ctx.ReleaseNotes,
|
||||
GoVersion: version,
|
||||
DockerImages: ctx.Dockers,
|
||||
Brews: ctx.Brews,
|
||||
})
|
||||
return out, err
|
||||
}
|
||||
|
@ -15,7 +15,12 @@ func TestDescribeBody(t *testing.T) {
|
||||
ReleaseNotes: changelog,
|
||||
Dockers: []string{
|
||||
"goreleaser/goreleaser:0.40.0",
|
||||
"goreleaser/godownloader:0.1.0",
|
||||
"goreleaser/goreleaser:latest",
|
||||
"goreleaser/godownloader:v0.1.0",
|
||||
},
|
||||
Brews: []string{
|
||||
"caarlos0/tap/foo",
|
||||
"goreleaser/tap/bar",
|
||||
},
|
||||
}
|
||||
out, err := describeBodyVersion(ctx, "go version go1.9 darwin/amd64")
|
||||
@ -28,7 +33,7 @@ func TestDescribeBody(t *testing.T) {
|
||||
assert.Equal(t, string(bts), out.String())
|
||||
}
|
||||
|
||||
func TestDescribeBodyNoDockerImages(t *testing.T) {
|
||||
func TestDescribeBodyNoDockerImagesNoBrews(t *testing.T) {
|
||||
var changelog = "\nfeature1: description\nfeature2: other description"
|
||||
var ctx = &context.Context{
|
||||
ReleaseNotes: changelog,
|
||||
|
12
pipeline/release/testdata/release1.txt
vendored
12
pipeline/release/testdata/release1.txt
vendored
@ -2,10 +2,16 @@
|
||||
feature1: description
|
||||
feature2: other description
|
||||
|
||||
Docker images:
|
||||
## Docker images
|
||||
|
||||
- goreleaser/goreleaser:0.40.0
|
||||
- goreleaser/godownloader:0.1.0
|
||||
- `docker pull goreleaser/goreleaser:0.40.0`
|
||||
- `docker pull goreleaser/goreleaser:latest`
|
||||
- `docker pull goreleaser/godownloader:v0.1.0`
|
||||
|
||||
## Homebrew taps
|
||||
|
||||
- `brew install caarlos0/tap/foo`
|
||||
- `brew install goreleaser/tap/bar`
|
||||
|
||||
---
|
||||
Automated with [GoReleaser](https://github.com/goreleaser)
|
||||
|
Loading…
Reference in New Issue
Block a user