1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-06-23 00:40:06 +02:00

feat: allow to use .Path and .Name on universal binary post hooks (#2891)

* feat: allow to use .Path and .Name on universal binary post hooks

This allows the usage of `{{ .Path }}` and `{{ .Name }}` on post
templates.

Closes #2890

* docs: improve docs

* test: add more tests
This commit is contained in:
Carlos Alexandro Becker
2022-02-08 11:44:47 -03:00
committed by GitHub
parent 5f30f3606a
commit c457d8fff7
3 changed files with 44 additions and 8 deletions

View File

@ -185,6 +185,7 @@ func TestRun(t *testing.T) {
},
Post: []config.Hook{
{Cmd: "touch " + post},
{Cmd: `sh -c 'echo "{{ .Name }} {{ .Os }} {{ .Arch }} {{ .Arm }} {{ .Target }} {{ .Ext }}" > {{ .Path }}.post'`, Output: true},
},
},
},
@ -268,6 +269,11 @@ func TestRun(t *testing.T) {
require.NoError(t, Pipe{}.Run(ctx5))
require.FileExists(t, pre)
require.FileExists(t, post)
post := filepath.Join(dist, "foo_darwin_all/foo.post")
require.FileExists(t, post)
bts, err := os.ReadFile(post)
require.NoError(t, err)
require.Equal(t, "foo darwin all darwin_all \n", string(bts))
})
t.Run("failing pre-hook", func(t *testing.T) {