mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
archive pipe fixed
This commit is contained in:
parent
d2d215feaa
commit
3c68b894c5
@ -28,6 +28,7 @@ type Context struct {
|
||||
Token string
|
||||
Git GitInfo
|
||||
Binaries map[string]string
|
||||
Folders map[string]string
|
||||
Artifacts []string
|
||||
ReleaseNotes string
|
||||
Version string
|
||||
@ -38,6 +39,7 @@ type Context struct {
|
||||
|
||||
var artifactsLock sync.Mutex
|
||||
var binariesLock sync.Mutex
|
||||
var foldersLock sync.Mutex
|
||||
|
||||
// AddArtifact adds a file to upload list
|
||||
func (ctx *Context) AddArtifact(file string) {
|
||||
@ -46,7 +48,7 @@ func (ctx *Context) AddArtifact(file string) {
|
||||
file = strings.TrimPrefix(file, ctx.Config.Dist)
|
||||
file = strings.Replace(file, "/", "", -1)
|
||||
ctx.Artifacts = append(ctx.Artifacts, file)
|
||||
log.WithField("artifact", file).Info("registered")
|
||||
log.WithField("artifact", file).Info("new artifact")
|
||||
}
|
||||
|
||||
// AddBinary adds a built binary to the current context
|
||||
@ -54,7 +56,15 @@ func (ctx *Context) AddBinary(key, file string) {
|
||||
binariesLock.Lock()
|
||||
defer binariesLock.Unlock()
|
||||
ctx.Binaries[key] = file
|
||||
log.WithField("key", key).WithField("binary", file).Info("added")
|
||||
log.WithField("key", key).WithField("binary", file).Info("new binary")
|
||||
}
|
||||
|
||||
// AddFolder adds a built binary to the current context
|
||||
func (ctx *Context) AddFolder(key, folder string) {
|
||||
foldersLock.Lock()
|
||||
defer foldersLock.Unlock()
|
||||
ctx.Folders[key] = folder
|
||||
log.WithField("key", key).WithField("folder", folder).Info("new folder")
|
||||
}
|
||||
|
||||
// New context
|
||||
@ -62,6 +72,7 @@ func New(config config.Project) *Context {
|
||||
return &Context{
|
||||
Context: ctx.Background(),
|
||||
Config: config,
|
||||
Archives: map[string]string{},
|
||||
Binaries: map[string]string{},
|
||||
Folders: map[string]string{},
|
||||
}
|
||||
}
|
||||
|
@ -27,19 +27,18 @@ func (Pipe) Description() string {
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
var g errgroup.Group
|
||||
// TODO: fix here
|
||||
for platform, archive := range ctx.Binaries {
|
||||
archive := archive
|
||||
for platform, folder := range ctx.Folders {
|
||||
folder := folder
|
||||
platform := platform
|
||||
g.Go(func() error {
|
||||
return create(ctx, platform, archive)
|
||||
return create(ctx, platform, folder)
|
||||
})
|
||||
}
|
||||
return g.Wait()
|
||||
}
|
||||
|
||||
func create(ctx *context.Context, platform, name string) error {
|
||||
var folder = filepath.Join(ctx.Config.Dist, ctx.Config.Name)
|
||||
var folder = filepath.Join(ctx.Config.Dist, name)
|
||||
var format = formatFor(ctx, platform)
|
||||
file, err := os.Create(folder + "." + format)
|
||||
if err != nil {
|
||||
|
@ -73,12 +73,13 @@ func doBuild(ctx *context.Context, build config.Build, target buildTarget) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.AddFolder(target.String(), folder)
|
||||
var binary = filepath.Join(
|
||||
ctx.Config.Dist,
|
||||
folder,
|
||||
build.Binary+ext.For(target.goos),
|
||||
)
|
||||
ctx.AddArchive(build.Binary+target.String(), binary)
|
||||
ctx.AddBinary(build.Binary+target.String(), binary)
|
||||
log.WithField("binary", binary).Info("building")
|
||||
cmd := []string{"go", "build"}
|
||||
if build.Flags != "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user