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:
parent
ffba3d6aa4
commit
e4048c2456
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user