1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/release/body.go

46 lines
988 B
Go
Raw Normal View History

2017-04-19 21:59:26 +02:00
package release
import (
"bytes"
"os/exec"
2017-07-04 14:28:26 +02:00
"text/template"
2017-04-19 21:59:26 +02:00
"github.com/goreleaser/goreleaser/context"
)
2017-04-19 22:05:10 +02:00
const bodyTemplate = `{{ .ReleaseNotes }}
2017-04-19 21:59:26 +02:00
{{- if .DockerImages }}
Docker images:
{{ range $element := .DockerImages }}
- {{ . -}}
{{ end -}}
{{- end }}
2017-04-19 21:59:26 +02:00
---
2017-07-02 22:40:21 +02:00
Automated with [GoReleaser](https://github.com/goreleaser)
Built with {{ .GoVersion }}`
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-04-19 21:59:26 +02:00
bts, err := exec.Command("go", "version").CombinedOutput()
if err != nil {
return bytes.Buffer{}, err
2017-04-19 21:59:26 +02:00
}
return describeBodyVersion(ctx, string(bts))
}
func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, error) {
var out bytes.Buffer
2017-04-19 21:59:26 +02:00
var template = template.Must(template.New("release").Parse(bodyTemplate))
err := template.Execute(&out, struct {
2017-04-19 22:05:10 +02:00
ReleaseNotes, GoVersion string
DockerImages []string
2017-04-19 21:59:26 +02:00
}{
2017-04-19 22:05:10 +02:00
ReleaseNotes: ctx.ReleaseNotes,
GoVersion: version,
DockerImages: ctx.Dockers,
2017-04-19 21:59:26 +02:00
})
return out, err
}