mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
Merge pull request #160 from goreleaser/linter-fixes
fixed several lint errors
This commit is contained in:
commit
77a384812e
@ -23,12 +23,8 @@ func (Pipe) Description() string {
|
|||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
func (Pipe) Run(ctx *context.Context) error {
|
func (Pipe) Run(ctx *context.Context) error {
|
||||||
if ctx.Config.Build.Hooks.Pre != "" {
|
if err := runHook(ctx.Config.Build.Hooks.Pre); err != nil {
|
||||||
log.Println("Running pre-build hook", ctx.Config.Build.Hooks.Pre)
|
return err
|
||||||
cmd := strings.Fields(ctx.Config.Build.Hooks.Pre)
|
|
||||||
if err := run(runtime.GOOS, runtime.GOARCH, cmd); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var g errgroup.Group
|
var g errgroup.Group
|
||||||
for _, goos := range ctx.Config.Build.Goos {
|
for _, goos := range ctx.Config.Build.Goos {
|
||||||
@ -51,14 +47,16 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
if err := g.Wait(); err != nil {
|
if err := g.Wait(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if ctx.Config.Build.Hooks.Post != "" {
|
return runHook(ctx.Config.Build.Hooks.Post)
|
||||||
log.Println("Running post-build hook", ctx.Config.Build.Hooks.Post)
|
}
|
||||||
cmd := strings.Fields(ctx.Config.Build.Hooks.Post)
|
|
||||||
if err := run(runtime.GOOS, runtime.GOARCH, cmd); err != nil {
|
func runHook(hook string) error {
|
||||||
return err
|
if hook == "" {
|
||||||
}
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
log.Println("Running hook", hook)
|
||||||
|
cmd := strings.Fields(hook)
|
||||||
|
return run(runtime.GOOS, runtime.GOARCH, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(name, goos, goarch string, ctx *context.Context) error {
|
func build(name, goos, goarch string, ctx *context.Context) error {
|
||||||
@ -77,10 +75,7 @@ func build(name, goos, goarch string, ctx *context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd = append(cmd, "-ldflags="+flags, "-o", output, ctx.Config.Build.Main)
|
cmd = append(cmd, "-ldflags="+flags, "-o", output, ctx.Config.Build.Main)
|
||||||
if err := run(goos, goarch, cmd); err != nil {
|
return run(goos, goarch, cmd)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(goos, goarch string, command []string) error {
|
func run(goos, goarch string, command []string) error {
|
||||||
|
2
pipeline/env/env_test.go
vendored
2
pipeline/env/env_test.go
vendored
@ -24,7 +24,7 @@ func TestValidEnv(t *testing.T) {
|
|||||||
|
|
||||||
func TestInvalidEnv(t *testing.T) {
|
func TestInvalidEnv(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
os.Unsetenv("GITHUB_TOKEN")
|
assert.NoError(os.Unsetenv("GITHUB_TOKEN"))
|
||||||
var ctx = &context.Context{
|
var ctx = &context.Context{
|
||||||
Config: config.Project{},
|
Config: config.Project{},
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
|||||||
}
|
}
|
||||||
// removes usual `v` prefix
|
// removes usual `v` prefix
|
||||||
ctx.Version = strings.TrimPrefix(tag, "v")
|
ctx.Version = strings.TrimPrefix(tag, "v")
|
||||||
if matches, err := regexp.MatchString("^[0-9.]+", ctx.Version); !matches || err != nil {
|
matches, err := regexp.MatchString("^[0-9.]+", ctx.Version)
|
||||||
|
if err != nil || !matches {
|
||||||
return ErrInvalidVersionFormat{ctx.Version}
|
return ErrInvalidVersionFormat{ctx.Version}
|
||||||
}
|
}
|
||||||
commit, err := commitHash()
|
commit, err := commitHash()
|
||||||
|
Loading…
Reference in New Issue
Block a user