1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-29 01:44:39 +02:00

feat: add base template function (#3834)

refs #3833

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-03-04 12:16:37 -03:00 committed by GitHub
parent 82144cb2c0
commit a40eb15618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 0 deletions

View File

@ -214,6 +214,7 @@ func (t *Template) Apply(s string) (string, error) {
"trimsuffix": strings.TrimSuffix,
"title": cases.Title(language.English).String,
"dir": filepath.Dir,
"base": filepath.Base,
"abs": filepath.Abs,
"incmajor": incMajor,
"incminor": incMinor,

View File

@ -73,6 +73,8 @@ func TestWithArtifact(t *testing.T) {
"artifact name: not-this-binary": "artifact name: {{ .ArtifactName }}",
"artifact ext: .exe": "artifact ext: {{ .ArtifactExt }}",
"artifact path: /tmp/foo.exe": "artifact path: {{ .ArtifactPath }}",
"artifact basename: foo.exe": "artifact basename: {{ base .ArtifactPath }}",
"artifact dir: /tmp": "artifact dir: {{ dir .ArtifactPath }}",
"remove this": "{{ filter .Env.MULTILINE \".*remove.*\" }}",
"something with\nmultiple lines\nto test things": "{{ reverseFilter .Env.MULTILINE \".*remove.*\" }}",

View File

@ -135,6 +135,7 @@ Usage |Description
`trimprefix "v1.2" "v"` |removes provided leading prefix string, if present. See [TrimPrefix](https://golang.org/pkg/strings/#TrimPrefix).
`trimsuffix "1.2v" "v"` |removes provided trailing suffix string, if present. See [TrimSuffix](https://pkg.go.dev/strings#TrimSuffix).
`dir .Path` |returns all but the last element of path, typically the path's directory. See [Dir](https://golang.org/pkg/path/filepath/#Dir).
`base .Path` |returns the last element of path. See [Base](https://golang.org/pkg/path/filepath/#Base). Since v1.16.
`abs .ArtifactPath` |returns an absolute representation of path. See [Abs](https://golang.org/pkg/path/filepath/#Abs).
`filter "text" "regex"` |keeps only the lines matching the given regex, analogous to `grep -E`. Since v1.6.
`reverseFilter "text" "regex"`|keeps only the lines **not** matching the given regex, analogous to `grep -vE`. Since v1.6.