1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-10-30 23:58:09 +02:00

fix: avoid duplicated files inside the archive

This commit is contained in:
Carlos Alexandro Becker
2018-01-21 12:59:15 -02:00
parent 6ff09f2992
commit 11329b0161
3 changed files with 22 additions and 4 deletions

12
Gopkg.lock generated
View File

@@ -16,6 +16,12 @@
revision = "70dc48d5d792f20f684a8f1d29bbac298f4b2ef4"
version = "v1.0.0"
[[projects]]
branch = "master"
name = "github.com/campoy/unique"
packages = ["."]
revision = "8da0a74979c676510b9de445041ce14b6e450e24"
[[projects]]
name = "github.com/davecgh/go-spew"
packages = ["spew"]
@@ -53,8 +59,8 @@
"tar",
"zip"
]
revision = "407d9188600f1b6584964bc532a5ce882cefdaba"
version = "v1.0.1"
revision = "35c6d4e271a22e46cc7133b7a6ae58b8e52acc01"
version = "v1.0.2"
[[projects]]
name = "github.com/masterminds/semver"
@@ -160,6 +166,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "29cc5012bc98dd429a87d7a638a221b2d0f5b12eaf5bea67576ffd362d88105b"
inputs-digest = "dd48a71cfd5292f26507d405996eb4ee06aea79c2308e6ee16e54fa6cd493832"
solver-name = "gps-cdcl"
solver-version = 1

View File

@@ -47,3 +47,7 @@
[[constraint]]
name = "github.com/fatih/color"
version = "1.5.0"
[[constraint]]
branch = "master"
name = "github.com/campoy/unique"

View File

@@ -10,6 +10,7 @@ import (
"strings"
"github.com/apex/log"
"github.com/campoy/unique"
"github.com/mattn/go-zglob"
"golang.org/x/sync/errgroup"
@@ -99,12 +100,15 @@ func create(ctx *context.Context, binaries []artifact.Artifact) error {
return fmt.Errorf("failed to find files to archive: %s", err.Error())
}
for _, f := range files {
log.Debugf("adding %s", f)
if err = a.Add(wrap(ctx, f, folder), f); err != nil {
return fmt.Errorf("failed to add %s to the archive: %s", f, err.Error())
}
}
for _, binary := range binaries {
if err := a.Add(wrap(ctx, binary.Name, folder), binary.Path); err != nil {
var bin = wrap(ctx, binary.Name, folder)
log.Debugf("adding %s", bin)
if err := a.Add(bin, binary.Path); err != nil {
return fmt.Errorf("failed to add %s -> %s to the archive: %s", binary.Path, binary.Name, err.Error())
}
}
@@ -142,6 +146,10 @@ func findFiles(ctx *context.Context) (result []string, err error) {
}
result = append(result, files...)
}
// remove duplicates
unique.Slice(&result, func(i, j int) bool {
return strings.Compare(result[i], result[j]) < 0
})
return
}