1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-20 03:59:26 +02:00
goreleaser/main.go

76 lines
1.8 KiB
Go
Raw Normal View History

2016-12-21 10:35:34 -02:00
package main
import (
2016-12-21 15:03:07 -02:00
"log"
2016-12-31 14:07:58 -02:00
"os"
2016-12-21 10:35:34 -02:00
2017-01-14 20:01:32 -02:00
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/pipeline"
2017-01-14 20:13:49 -02:00
"github.com/goreleaser/goreleaser/pipeline/archive"
2017-01-14 20:01:32 -02:00
"github.com/goreleaser/goreleaser/pipeline/brew"
"github.com/goreleaser/goreleaser/pipeline/build"
"github.com/goreleaser/goreleaser/pipeline/defaults"
"github.com/goreleaser/goreleaser/pipeline/env"
"github.com/goreleaser/goreleaser/pipeline/git"
"github.com/goreleaser/goreleaser/pipeline/release"
"github.com/goreleaser/goreleaser/pipeline/repos"
"github.com/goreleaser/goreleaser/pipeline/source"
2016-12-31 13:57:39 -02:00
"github.com/urfave/cli"
2016-12-21 10:35:34 -02:00
)
2016-12-29 18:10:11 -02:00
var version = "master"
2016-12-21 14:42:23 -02:00
2016-12-31 13:57:39 -02:00
var pipes = []pipeline.Pipe{
2017-01-14 14:06:57 -02:00
// load data, set defaults, etc...
2017-01-14 12:34:22 -02:00
defaults.Pipe{},
2017-01-14 14:06:57 -02:00
env.Pipe{},
2017-01-14 12:34:22 -02:00
git.Pipe{},
2017-01-14 14:06:57 -02:00
repos.Pipe{},
&source.Pipe{},
2017-01-14 14:06:57 -02:00
// real work
2016-12-31 13:57:39 -02:00
build.Pipe{},
archive.Pipe{},
2016-12-31 13:57:39 -02:00
release.Pipe{},
brew.Pipe{},
}
2016-12-21 10:35:34 -02:00
func main() {
2016-12-31 13:57:39 -02:00
var app = cli.NewApp()
2017-01-18 15:45:42 -02:00
app.Name = "goreleaser"
2016-12-31 13:57:39 -02:00
app.Version = version
app.Usage = "Deliver Go binaries as fast and easily as possible"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "Load configuration from `FILE`",
Value: "goreleaser.yml",
},
2016-12-28 22:23:39 -02:00
}
2017-01-21 19:11:54 -02:00
app.Action = func(c *cli.Context) (err error) {
2016-12-31 13:57:39 -02:00
var file = c.String("config")
2017-01-14 19:29:57 +01:00
cfg, err := config.Load(file)
// Allow failing to load the config file if file is not explicitly specified
if err != nil && c.IsSet("config") {
2016-12-31 13:57:39 -02:00
return cli.NewExitError(err.Error(), 1)
}
ctx := context.New(cfg)
2017-01-14 14:06:57 -02:00
log.SetFlags(0)
2017-01-21 19:11:54 -02:00
for _, pipe := range pipes {
log.Println(pipe.Description())
log.SetPrefix(" -> ")
if err := pipe.Run(ctx); err != nil {
return cli.NewExitError(err.Error(), 1)
}
log.SetPrefix("")
2016-12-29 09:58:22 -02:00
}
2016-12-31 13:57:39 -02:00
log.Println("Done!")
2017-01-21 19:11:54 -02:00
return
2016-12-21 15:03:07 -02:00
}
2017-01-02 13:20:33 -02:00
if err := app.Run(os.Args); err != nil {
log.Fatalln(err)
}
2016-12-21 10:35:34 -02:00
}