mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
fix: Compile template at startup
Fail as fast as possible.
This commit is contained in:
parent
3e05553418
commit
21aa07766c
@ -9,7 +9,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
)
|
||||
|
||||
const bodyTemplate = `{{ .ReleaseNotes }}
|
||||
const bodyTemplateText = `{{ .ReleaseNotes }}
|
||||
|
||||
{{- if .DockerImages }}
|
||||
|
||||
@ -23,6 +23,12 @@ const bodyTemplate = `{{ .ReleaseNotes }}
|
||||
Automated with [GoReleaser](https://github.com/goreleaser)
|
||||
Built with {{ .GoVersion }}`
|
||||
|
||||
var bodyTemplate *template.Template
|
||||
|
||||
func init() {
|
||||
bodyTemplate = template.Must(template.New("release").Parse(bodyTemplateText))
|
||||
}
|
||||
|
||||
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
|
||||
/* #nosec */
|
||||
bts, err := exec.CommandContext(ctx, "go", "version").CombinedOutput()
|
||||
@ -34,12 +40,11 @@ func describeBody(ctx *context.Context) (bytes.Buffer, error) {
|
||||
|
||||
func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, error) {
|
||||
var out bytes.Buffer
|
||||
var template = template.Must(template.New("release").Parse(bodyTemplate))
|
||||
var dockers []string
|
||||
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
|
||||
dockers = append(dockers, a.Name)
|
||||
}
|
||||
err := template.Execute(&out, struct {
|
||||
err := bodyTemplate.Execute(&out, struct {
|
||||
ReleaseNotes, GoVersion string
|
||||
DockerImages []string
|
||||
}{
|
||||
|
Loading…
Reference in New Issue
Block a user