mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
46 lines
988 B
Go
46 lines
988 B
Go
package release
|
|
|
|
import (
|
|
"bytes"
|
|
"os/exec"
|
|
"text/template"
|
|
|
|
"github.com/goreleaser/goreleaser/context"
|
|
)
|
|
|
|
const bodyTemplate = `{{ .ReleaseNotes }}
|
|
|
|
{{- if .DockerImages }}
|
|
|
|
Docker images:
|
|
{{ range $element := .DockerImages }}
|
|
- {{ . -}}
|
|
{{ end -}}
|
|
{{- end }}
|
|
|
|
---
|
|
Automated with [GoReleaser](https://github.com/goreleaser)
|
|
Built with {{ .GoVersion }}`
|
|
|
|
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
|
|
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
|
|
}{
|
|
ReleaseNotes: ctx.ReleaseNotes,
|
|
GoVersion: version,
|
|
DockerImages: ctx.Dockers,
|
|
})
|
|
return out, err
|
|
}
|