1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-11-06 09:09:29 +02:00

feat: Use GitLab Direct Asset Links (#2219)

* feat: Use GitLab Direct Asset Links

Implement the use of Direct Asset Links when uploading artifacts to a GitLab release

* fix: Remove ArtifactUploadHash

As GitLab support for direct asset linking exists, remove ArtifactUploadHash due to it no longer being required

* test: fix unit tests for gitlab urls

* fix: Use artifact name during GitLab upload

file.Name() included the path to the file, which isn't needed and breaks other areas such as homebrew releases

* docs: Require GitLab version v12.9+

Due to newly introduced dependency on direct asset linking
This commit is contained in:
Matt Palmer
2021-05-17 18:33:04 +01:00
committed by GitHub
parent 513503644e
commit bf4359017b
12 changed files with 29 additions and 131 deletions

View File

@@ -55,9 +55,6 @@ const (
artifactName = "ArtifactName"
artifactPath = "ArtifactPath"
// gitlab only.
artifactUploadHash = "ArtifactUploadHash"
// build keys.
name = "Name"
ext = "Ext"
@@ -135,11 +132,6 @@ func (t *Template) WithArtifact(a *artifact.Artifact, replacements map[string]st
t.fields[binary] = bin.(string)
t.fields[artifactName] = a.Name
t.fields[artifactPath] = a.Path
if val, ok := a.Extra["ArtifactUploadHash"]; ok {
t.fields[artifactUploadHash] = val
} else {
t.fields[artifactUploadHash] = ""
}
return t
}

View File

@@ -47,7 +47,6 @@ func TestWithArtifact(t *testing.T) {
"shortcommit": "{{.ShortCommit}}",
"binary": "{{.Binary}}",
"proj": "{{.ProjectName}}",
"": "{{.ArtifactUploadHash}}",
"github.com/goreleaser/goreleaser": "{{ .ModulePath }}",
} {
tmpl := tmpl
@@ -72,24 +71,6 @@ func TestWithArtifact(t *testing.T) {
})
}
t.Run("artifact with gitlab ArtifactUploadHash", func(t *testing.T) {
t.Parallel()
uploadHash := "820ead5d9d2266c728dce6d4d55b6460"
result, err := New(ctx).WithArtifact(
&artifact.Artifact{
Name: "another-binary",
Goarch: "amd64",
Goos: "linux",
Goarm: "6",
Extra: map[string]interface{}{
"ArtifactUploadHash": uploadHash,
},
}, map[string]string{},
).Apply("{{ .ArtifactUploadHash }}")
require.NoError(t, err)
require.Equal(t, uploadHash, result)
})
t.Run("artifact without binary name", func(t *testing.T) {
t.Parallel()
result, err := New(ctx).WithArtifact(