2017-04-21 20:25:32 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-22 02:58:59 +02:00
|
|
|
"fmt"
|
2017-04-21 20:25:32 +02:00
|
|
|
"os"
|
|
|
|
|
2017-06-22 05:09:14 +02:00
|
|
|
"github.com/apex/log"
|
2017-06-22 05:38:24 +02:00
|
|
|
lcli "github.com/apex/log/handlers/cli"
|
2017-04-23 13:22:12 +02:00
|
|
|
"github.com/goreleaser/goreleaser/goreleaserlib"
|
2017-04-21 20:25:32 +02:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
version = "dev"
|
|
|
|
commit = "none"
|
|
|
|
date = "unknown"
|
|
|
|
)
|
|
|
|
|
2017-06-22 05:09:14 +02:00
|
|
|
func init() {
|
|
|
|
log.SetHandler(lcli.New(os.Stdout))
|
|
|
|
}
|
|
|
|
|
2017-04-21 20:25:32 +02:00
|
|
|
func main() {
|
|
|
|
var app = cli.NewApp()
|
|
|
|
app.Name = "goreleaser"
|
2017-04-22 02:58:59 +02:00
|
|
|
app.Version = fmt.Sprintf("%v, commit %v, built at %v", version, commit, date)
|
2017-04-21 20:25:32 +02:00
|
|
|
app.Usage = "Deliver Go binaries as fast and easily as possible"
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "config, file, c, f",
|
|
|
|
Usage: "Load configuration from `FILE`",
|
|
|
|
Value: "goreleaser.yml",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "release-notes",
|
|
|
|
Usage: "Load custom release notes from a markdown `FILE`",
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "skip-validate",
|
|
|
|
Usage: "Skip all the validations against the release",
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "skip-publish",
|
|
|
|
Usage: "Skip all publishing pipes of the release",
|
|
|
|
},
|
2017-04-29 12:49:22 +02:00
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "snapshot",
|
|
|
|
Usage: "Generate an unversioned snapshot release",
|
|
|
|
},
|
2017-06-22 05:25:52 +02:00
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "debug",
|
|
|
|
Usage: "Enable debug mode",
|
|
|
|
},
|
2017-04-21 20:25:32 +02:00
|
|
|
}
|
|
|
|
app.Action = func(c *cli.Context) error {
|
2017-06-22 15:47:34 +02:00
|
|
|
log.Infof("running goreleaser %v", version)
|
2017-04-23 13:22:12 +02:00
|
|
|
if err := goreleaserlib.Release(c); err != nil {
|
2017-04-21 20:25:32 +02:00
|
|
|
return cli.NewExitError(err.Error(), 1)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-04-27 11:03:26 +02:00
|
|
|
app.Commands = []cli.Command{
|
|
|
|
{
|
|
|
|
Name: "init",
|
|
|
|
Aliases: []string{"i"},
|
|
|
|
Usage: "generate goreleaser.yml",
|
|
|
|
Action: func(c *cli.Context) error {
|
2017-04-28 13:25:29 +02:00
|
|
|
var filename = "goreleaser.yml"
|
2017-04-28 15:47:15 +02:00
|
|
|
if err := goreleaserlib.InitProject(filename); err != nil {
|
|
|
|
return cli.NewExitError(err.Error(), 1)
|
2017-04-27 11:03:26 +02:00
|
|
|
}
|
|
|
|
|
2017-06-22 15:47:34 +02:00
|
|
|
log.WithField("file", filename).
|
|
|
|
Info("config create, please edit accordingly to your needs")
|
2017-04-27 11:03:26 +02:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2017-04-21 20:25:32 +02:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
2017-06-22 15:47:34 +02:00
|
|
|
log.WithError(err).Fatal("failed")
|
2017-04-21 20:25:32 +02:00
|
|
|
}
|
|
|
|
}
|