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

73 lines
1.7 KiB
Go
Raw Normal View History

2016-12-21 14:35:34 +02:00
package main
import (
2016-12-21 19:03:07 +02:00
"log"
2016-12-31 18:07:58 +02:00
"os"
2016-12-21 14:35:34 +02:00
"github.com/goreleaser/releaser/config"
2017-01-14 16:34:22 +02:00
"github.com/goreleaser/releaser/context"
2016-12-30 13:27:35 +02:00
"github.com/goreleaser/releaser/pipeline"
"github.com/goreleaser/releaser/pipeline/brew"
"github.com/goreleaser/releaser/pipeline/build"
"github.com/goreleaser/releaser/pipeline/compress"
2017-01-14 16:34:22 +02:00
"github.com/goreleaser/releaser/pipeline/defaults"
2017-01-14 18:06:57 +02:00
"github.com/goreleaser/releaser/pipeline/env"
2017-01-14 16:34:22 +02:00
"github.com/goreleaser/releaser/pipeline/git"
2016-12-30 13:27:35 +02:00
"github.com/goreleaser/releaser/pipeline/release"
2017-01-14 16:34:22 +02:00
"github.com/goreleaser/releaser/pipeline/repos"
2016-12-31 17:57:39 +02:00
"github.com/urfave/cli"
2016-12-21 14:35:34 +02:00
)
2016-12-29 22:10:11 +02:00
var version = "master"
2016-12-21 18:42:23 +02:00
2016-12-31 17:57:39 +02:00
var pipes = []pipeline.Pipe{
2017-01-14 18:06:57 +02:00
// load data, set defaults, etc...
2017-01-14 16:34:22 +02:00
defaults.Pipe{},
2017-01-14 18:06:57 +02:00
env.Pipe{},
2017-01-14 16:34:22 +02:00
git.Pipe{},
2017-01-14 18:06:57 +02:00
repos.Pipe{},
// real work
2016-12-31 17:57:39 +02:00
build.Pipe{},
compress.Pipe{},
release.Pipe{},
brew.Pipe{},
}
2016-12-21 14:35:34 +02:00
func main() {
2016-12-31 17:57:39 +02:00
var app = cli.NewApp()
app.Name = "release"
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-29 02:23:39 +02:00
}
2016-12-31 17:57:39 +02:00
app.Action = func(c *cli.Context) (err error) {
var file = c.String("config")
2017-01-14 20:29:57 +02: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 17:57:39 +02:00
return cli.NewExitError(err.Error(), 1)
}
2017-01-14 20:29:57 +02:00
context := context.New(cfg)
2017-01-14 18:06:57 +02:00
log.SetFlags(0)
2016-12-31 17:57:39 +02:00
for _, pipe := range pipes {
2017-01-14 19:14:35 +02:00
log.Println(pipe.Description())
2017-01-14 18:06:57 +02:00
log.SetPrefix(" -> ")
2017-01-14 16:34:22 +02:00
if err := pipe.Run(context); err != nil {
2017-01-14 19:14:35 +02:00
return cli.NewExitError(err.Error(), 1)
2016-12-31 17:57:39 +02:00
}
2017-01-14 18:06:57 +02:00
log.SetPrefix("")
2016-12-29 13:58:22 +02:00
}
2016-12-31 17:57:39 +02:00
log.Println("Done!")
return
2016-12-21 19:03:07 +02:00
}
2017-01-02 17:20:33 +02:00
if err := app.Run(os.Args); err != nil {
log.Fatalln(err)
}
2016-12-21 14:35:34 +02:00
}