2017-04-19 21:59:26 +02:00
|
|
|
package release
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2017-07-04 14:28:26 +02:00
|
|
|
"text/template"
|
2017-04-19 21:59:26 +02:00
|
|
|
|
2017-12-18 03:11:17 +02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/artifact"
|
2018-08-15 04:50:20 +02:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2017-04-19 21:59:26 +02:00
|
|
|
)
|
|
|
|
|
2018-02-01 15:37:30 +02:00
|
|
|
const bodyTemplateText = `{{ .ReleaseNotes }}
|
2017-04-19 21:59:26 +02:00
|
|
|
|
2018-04-01 18:27:57 +02:00
|
|
|
{{- with .DockerImages }}
|
2017-09-16 20:31:20 +02:00
|
|
|
|
2017-12-05 22:19:18 +02:00
|
|
|
## Docker images
|
2018-04-01 18:27:57 +02:00
|
|
|
{{ range $element := . }}
|
2017-12-05 22:19:18 +02:00
|
|
|
- ` + "`docker pull {{ . -}}`" + `
|
|
|
|
{{- end -}}
|
2018-04-01 20:24:59 +02:00
|
|
|
{{- end }}
|
|
|
|
`
|
2017-04-19 21:59:26 +02:00
|
|
|
|
2017-04-19 22:12:12 +02:00
|
|
|
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
|
2017-09-16 20:31:20 +02:00
|
|
|
var out bytes.Buffer
|
2018-07-04 09:42:24 +02:00
|
|
|
// nolint:prealloc
|
2017-12-18 03:11:17 +02:00
|
|
|
var dockers []string
|
|
|
|
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
|
|
|
|
dockers = append(dockers, a.Name)
|
|
|
|
}
|
2018-11-08 02:04:49 +02:00
|
|
|
var bodyTemplate = template.Must(template.New("release").Parse(bodyTemplateText))
|
2018-02-01 15:37:30 +02:00
|
|
|
err := bodyTemplate.Execute(&out, struct {
|
2018-04-01 18:27:57 +02:00
|
|
|
ReleaseNotes string
|
|
|
|
DockerImages []string
|
2017-04-19 21:59:26 +02:00
|
|
|
}{
|
2017-04-19 22:05:10 +02:00
|
|
|
ReleaseNotes: ctx.ReleaseNotes,
|
2017-12-18 03:11:17 +02:00
|
|
|
DockerImages: dockers,
|
2017-04-19 21:59:26 +02:00
|
|
|
})
|
|
|
|
return out, err
|
|
|
|
}
|