diff --git a/nfpm.go b/nfpm.go index 3b347e0..dfa7224 100644 --- a/nfpm.go +++ b/nfpm.go @@ -159,7 +159,8 @@ func (c *Config) expandEnvVars() { } } - // Vendor field + // Maintainer and vendor fields + c.Info.Maintainer = os.Expand(c.Info.Maintainer, c.envMappingFunc) c.Info.Vendor = os.Expand(c.Info.Vendor, c.envMappingFunc) // Package signing related fields diff --git a/nfpm_test.go b/nfpm_test.go index 4970299..337cdc4 100644 --- a/nfpm_test.go +++ b/nfpm_test.go @@ -237,14 +237,15 @@ func TestParseEnhancedNestedNoGlob(t *testing.T) { func TestOptionsFromEnvironment(t *testing.T) { const ( - globalPass = "hunter2" - debPass = "password123" - rpmPass = "secret" - apkPass = "foobar" - release = "3" - version = "1.0.0" - vendor = "GoReleaser" - packager = "nope" + globalPass = "hunter2" + debPass = "password123" + rpmPass = "secret" + apkPass = "foobar" + release = "3" + version = "1.0.0" + vendor = "GoReleaser" + packager = "nope" + maintainerEmail = "nope@example.com" ) t.Run("version", func(t *testing.T) { @@ -263,6 +264,15 @@ func TestOptionsFromEnvironment(t *testing.T) { require.Equal(t, release, info.Release) }) + t.Run("maintainer", func(t *testing.T) { + os.Clearenv() + os.Setenv("GIT_COMMITTER_NAME", packager) + os.Setenv("GIT_COMMITTER_EMAIL", maintainerEmail) + info, err := nfpm.Parse(strings.NewReader("name: foo\nmaintainer: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>")) + require.NoError(t, err) + require.Equal(t, fmt.Sprintf("%s <%s>", packager, maintainerEmail), info.Maintainer) + }) + t.Run("vendor", func(t *testing.T) { os.Clearenv() os.Setenv("VENDOR", vendor) diff --git a/www/docs/configuration.md b/www/docs/configuration.md index ae866aa..ae227fc 100644 --- a/www/docs/configuration.md +++ b/www/docs/configuration.md @@ -55,6 +55,7 @@ section: default priority: extra # Maintainer. +# This will expand any env var you set in the field, eg maintainer: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}> # Defaults to empty on rpm and apk # Leaving the 'maintainer' field unset will not be allowed in a future version maintainer: Carlos Alexandro Becker