1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

44 lines
1010 B
Go
Raw Normal View History

2017-04-19 16:59:26 -03:00
package release
import (
"bytes"
2017-07-04 09:28:26 -03:00
"text/template"
2017-04-19 16:59:26 -03:00
2017-12-17 23:11:17 -02:00
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/pkg/context"
2017-04-19 16:59:26 -03:00
)
const bodyTemplateText = `{{ .ReleaseNotes }}
2017-04-19 16:59:26 -03:00
{{- with .DockerImages }}
## Docker images
{{ range $element := . }}
- ` + "`docker pull {{ . -}}`" + `
{{- end -}}
2018-04-01 15:24:59 -03:00
{{- end }}
`
2017-04-19 16:59:26 -03:00
2017-04-19 17:12:12 -03:00
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
var out bytes.Buffer
2018-07-04 00:42:24 -07:00
// nolint:prealloc
2017-12-17 23:11:17 -02:00
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)
}
2017-12-17 23:11:17 -02:00
}
2018-11-07 22:04:49 -02:00
var bodyTemplate = template.Must(template.New("release").Parse(bodyTemplateText))
err := bodyTemplate.Execute(&out, struct {
ReleaseNotes string
DockerImages []string
2017-04-19 16:59:26 -03:00
}{
2017-04-19 17:05:10 -03:00
ReleaseNotes: ctx.ReleaseNotes,
2017-12-17 23:11:17 -02:00
DockerImages: dockers,
2017-04-19 16:59:26 -03:00
})
return out, err
}