mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-03 13:11:48 +02:00
feat: ArtifactExt as a template field
This commit is contained in:
parent
a05b776334
commit
a31b4aa0ae
@ -63,6 +63,7 @@ const (
|
||||
mips = "Mips"
|
||||
binary = "Binary"
|
||||
artifactName = "ArtifactName"
|
||||
artifactExt = "ArtifactExt"
|
||||
artifactPath = "ArtifactPath"
|
||||
|
||||
// build keys.
|
||||
@ -146,6 +147,7 @@ func (t *Template) WithArtifact(a *artifact.Artifact, replacements map[string]st
|
||||
t.fields[amd64] = replace(replacements, a.Goamd64)
|
||||
t.fields[binary] = artifact.ExtraOr(*a, binary, t.fields[projectName].(string))
|
||||
t.fields[artifactName] = a.Name
|
||||
t.fields[artifactExt] = artifact.ExtraOr(*a, artifact.ExtraExt, "")
|
||||
t.fields[artifactPath] = a.Path
|
||||
return t
|
||||
}
|
||||
|
@ -69,6 +69,9 @@ func TestWithArtifact(t *testing.T) {
|
||||
"another line": "{{ .TagBody }}",
|
||||
"runtime: " + runtime.GOOS: "runtime: {{ .Runtime.Goos }}",
|
||||
"runtime: " + runtime.GOARCH: "runtime: {{ .Runtime.Goarch }}",
|
||||
"artifact name: not-this-binary": "artifact name: {{ .ArtifactName }}",
|
||||
"artifact ext: .exe": "artifact ext: {{ .ArtifactExt }}",
|
||||
"artifact path: /tmp/foo.exe": "artifact path: {{ .ArtifactPath }}",
|
||||
|
||||
"remove this": "{{ filter .Env.MULTILINE \".*remove.*\" }}",
|
||||
"something with\nmultiple lines\nto test things": "{{ reverseFilter .Env.MULTILINE \".*remove.*\" }}",
|
||||
@ -80,6 +83,7 @@ func TestWithArtifact(t *testing.T) {
|
||||
result, err := New(ctx).WithArtifact(
|
||||
&artifact.Artifact{
|
||||
Name: "not-this-binary",
|
||||
Path: "/tmp/foo.exe",
|
||||
Goarch: "amd64",
|
||||
Goos: "linux",
|
||||
Goarm: "6",
|
||||
@ -87,6 +91,7 @@ func TestWithArtifact(t *testing.T) {
|
||||
Goamd64: "v3",
|
||||
Extra: map[string]interface{}{
|
||||
artifact.ExtraBinary: "binary",
|
||||
artifact.ExtraExt: ".exe",
|
||||
},
|
||||
},
|
||||
map[string]string{"linux": "Linux"},
|
||||
|
@ -72,6 +72,7 @@ may have some extra fields:
|
||||
| `.Binary` | binary name |
|
||||
| `.ArtifactName` | archive name |
|
||||
| `.ArtifactPath` | absolute path to artifact |
|
||||
| `.ArtifactExt` | binary extension (e.g. `.exe`) |
|
||||
|
||||
[^8]: Might have been replaced by `archives.replacements`.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user