You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-09-16 09:26:52 +02:00
archive pipe fixed
This commit is contained in:
@@ -28,6 +28,7 @@ type Context struct {
|
|||||||
Token string
|
Token string
|
||||||
Git GitInfo
|
Git GitInfo
|
||||||
Binaries map[string]string
|
Binaries map[string]string
|
||||||
|
Folders map[string]string
|
||||||
Artifacts []string
|
Artifacts []string
|
||||||
ReleaseNotes string
|
ReleaseNotes string
|
||||||
Version string
|
Version string
|
||||||
@@ -38,6 +39,7 @@ type Context struct {
|
|||||||
|
|
||||||
var artifactsLock sync.Mutex
|
var artifactsLock sync.Mutex
|
||||||
var binariesLock sync.Mutex
|
var binariesLock sync.Mutex
|
||||||
|
var foldersLock sync.Mutex
|
||||||
|
|
||||||
// AddArtifact adds a file to upload list
|
// AddArtifact adds a file to upload list
|
||||||
func (ctx *Context) AddArtifact(file string) {
|
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.TrimPrefix(file, ctx.Config.Dist)
|
||||||
file = strings.Replace(file, "/", "", -1)
|
file = strings.Replace(file, "/", "", -1)
|
||||||
ctx.Artifacts = append(ctx.Artifacts, file)
|
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
|
// AddBinary adds a built binary to the current context
|
||||||
@@ -54,7 +56,15 @@ func (ctx *Context) AddBinary(key, file string) {
|
|||||||
binariesLock.Lock()
|
binariesLock.Lock()
|
||||||
defer binariesLock.Unlock()
|
defer binariesLock.Unlock()
|
||||||
ctx.Binaries[key] = file
|
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
|
// New context
|
||||||
@@ -62,6 +72,7 @@ func New(config config.Project) *Context {
|
|||||||
return &Context{
|
return &Context{
|
||||||
Context: ctx.Background(),
|
Context: ctx.Background(),
|
||||||
Config: config,
|
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
|
// Run the pipe
|
||||||
func (Pipe) Run(ctx *context.Context) error {
|
func (Pipe) Run(ctx *context.Context) error {
|
||||||
var g errgroup.Group
|
var g errgroup.Group
|
||||||
// TODO: fix here
|
for platform, folder := range ctx.Folders {
|
||||||
for platform, archive := range ctx.Binaries {
|
folder := folder
|
||||||
archive := archive
|
|
||||||
platform := platform
|
platform := platform
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
return create(ctx, platform, archive)
|
return create(ctx, platform, folder)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return g.Wait()
|
return g.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func create(ctx *context.Context, platform, name string) error {
|
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)
|
var format = formatFor(ctx, platform)
|
||||||
file, err := os.Create(folder + "." + format)
|
file, err := os.Create(folder + "." + format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -73,12 +73,13 @@ func doBuild(ctx *context.Context, build config.Build, target buildTarget) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
ctx.AddFolder(target.String(), folder)
|
||||||
var binary = filepath.Join(
|
var binary = filepath.Join(
|
||||||
ctx.Config.Dist,
|
ctx.Config.Dist,
|
||||||
folder,
|
folder,
|
||||||
build.Binary+ext.For(target.goos),
|
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")
|
log.WithField("binary", binary).Info("building")
|
||||||
cmd := []string{"go", "build"}
|
cmd := []string{"go", "build"}
|
||||||
if build.Flags != "" {
|
if build.Flags != "" {
|
||||||
|
Reference in New Issue
Block a user