1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00
Frank Schroeder 1c2afe148f fix: move env vars to context
In preparation to support env vars for Docker tag_template and also to
simplify the tests by not chaning the global os.Environ I've moved the
parsed env var map into the context.Context.
2017-12-05 21:42:04 -02:00

36 lines
694 B
Go

package build
import (
"bytes"
"text/template"
"time"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
)
type ldflagsData struct {
Date string
Tag string
Commit string
Version string
Env map[string]string
}
func ldflags(ctx *context.Context, build config.Build) (string, error) {
var data = ldflagsData{
Commit: ctx.Git.Commit,
Tag: ctx.Git.CurrentTag,
Version: ctx.Version,
Date: time.Now().UTC().Format(time.RFC3339),
Env: ctx.Env,
}
var out bytes.Buffer
t, err := template.New("ldflags").Parse(build.Ldflags)
if err != nil {
return "", err
}
err = t.Execute(&out, data)
return out.String(), err
}