1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00

feat: expand env on build envs

This commit is contained in:
Carlos Alexandro Becker 2018-02-12 20:53:57 -02:00 committed by Carlos Alexandro Becker
parent ffba3d6aa4
commit e4048c2456
2 changed files with 21 additions and 0 deletions

View File

@ -58,6 +58,9 @@ func buildWithDefaults(ctx *context.Context, build config.Build) config.Build {
if build.Binary == "" {
build.Binary = ctx.Config.Release.GitHub.Name
}
for k, v := range build.Env {
build.Env[k] = os.ExpandEnv(v)
}
return builders.For(build.Lang).WithDefaults(build)
}

View File

@ -165,6 +165,24 @@ func TestDefaultNoBuilds(t *testing.T) {
assert.NoError(t, Pipe{}.Default(ctx))
}
func TestDefaultExpandEnv(t *testing.T) {
assert.NoError(t, os.Setenv("BAR", "FOOBAR"))
var ctx = &context.Context{
Config: config.Project{
Builds: []config.Build{
{
Env: []string{
"FOO=bar_$BAR",
},
},
},
},
}
assert.NoError(t, Pipe{}.Default(ctx))
var env = ctx.Config.Builds[0].Env[0]
assert.Equal(t, "FOO=bar_FOOBAR", env)
}
func TestDefaultEmptyBuild(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{