1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

refactor: changed code on build pipe

This commit is contained in:
Carlos Alexandro Becker 2017-12-17 15:24:49 -02:00
parent 375940841f
commit b9cc820e1d
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 17 additions and 21 deletions

View File

@ -20,7 +20,7 @@ const (
// Artifact represents an artifact and its relevant info
type Artifact struct {
Name string
Folder string
Path string
Goos string
Goarch string
Goarm string

View File

@ -1,4 +1,4 @@
package build
package archive
import (
"bytes"

View File

@ -7,12 +7,14 @@ import (
"strings"
"github.com/apex/log"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/buildtarget"
"github.com/goreleaser/goreleaser/internal/ext"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/buildtarget"
"github.com/goreleaser/goreleaser/internal/ext"
)
// Pipe for build
@ -105,21 +107,15 @@ func runHook(env []string, hook string) error {
func doBuild(ctx *context.Context, build config.Build, target buildtarget.Target) error {
var binaryName = build.Binary + ext.For(target)
var prettyName = binaryName
if ctx.Config.Archive.Format == "binary" {
var err error
binaryName, err = nameFor(ctx, target, build.Binary)
if err != nil {
return err
}
binaryName = binaryName + ext.For(target)
}
folder, err := nameFor(ctx, target, ctx.Config.ProjectName)
if err != nil {
return err
}
var binary = filepath.Join(ctx.Config.Dist, folder, binaryName)
ctx.AddBinary(target.String(), folder, prettyName, binary)
var binary = filepath.Join(ctx.Config.Dist, target.String(), binaryName)
ctx.Artifacts.Add(artifact.Artifact{
Type: artifact.Binary,
Path: binary,
Name: binaryName,
Goos: target.OS,
Goarch: target.Arch,
Goarm: target.Arm,
})
log.WithField("binary", binary).Info("building")
cmd := []string{"go", "build"}
if build.Flags != "" {