1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipe/release/body.go
Carlos Alexandro Becker 8fa7c6977a feat: add only the manifests to the release notes
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-11-30 21:53:36 -03:00

44 lines
1010 B
Go

package release
import (
"bytes"
"text/template"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/pkg/context"
)
const bodyTemplateText = `{{ .ReleaseNotes }}
{{- with .DockerImages }}
## Docker images
{{ range $element := . }}
- ` + "`docker pull {{ . -}}`" + `
{{- end -}}
{{- end }}
`
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
var out bytes.Buffer
// nolint:prealloc
var dockers []string
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerManifest)).List() {
dockers = append(dockers, a.Name)
}
if len(dockers) == 0 {
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
dockers = append(dockers, a.Name)
}
}
var bodyTemplate = template.Must(template.New("release").Parse(bodyTemplateText))
err := bodyTemplate.Execute(&out, struct {
ReleaseNotes string
DockerImages []string
}{
ReleaseNotes: ctx.ReleaseNotes,
DockerImages: dockers,
})
return out, err
}