1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
Carlos Alexandro Becker e87ab21a0a feat: improved release notes
- Added homebrew taps
- Docker pull commands instead of list of docker imgs
2017-12-06 00:13:24 -02:00

57 lines
1.2 KiB
Go

package release
import (
"bytes"
"os/exec"
"text/template"
"github.com/goreleaser/goreleaser/context"
)
const bodyTemplate = `{{ .ReleaseNotes }}
{{- if .DockerImages }}
## Docker images
{{ range $element := .DockerImages }}
- ` + "`docker pull {{ . -}}`" + `
{{- end -}}
{{- end }}
{{- if .Brews }}
## Homebrew taps
{{ range $element := .Brews }}
- ` + "`brew install {{ . -}}`" + `
{{- end -}}
{{- end }}
---
Automated with [GoReleaser](https://github.com/goreleaser)
Built with {{ .GoVersion }}`
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
/* #nosec */
bts, err := exec.Command("go", "version").CombinedOutput()
if err != nil {
return bytes.Buffer{}, err
}
return describeBodyVersion(ctx, string(bts))
}
func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, error) {
var out bytes.Buffer
var template = template.Must(template.New("release").Parse(bodyTemplate))
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
}