1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/main.go

70 lines
1.5 KiB
Go
Raw Normal View History

2017-04-21 15:25:32 -03:00
package main
import (
2017-04-21 21:58:59 -03:00
"fmt"
2017-04-21 15:25:32 -03:00
"log"
"os"
"github.com/goreleaser/goreleaser/goreleaserlib"
2017-04-21 15:25:32 -03:00
"github.com/urfave/cli"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
var app = cli.NewApp()
app.Name = "goreleaser"
2017-04-21 21:58:59 -03:00
app.Version = fmt.Sprintf("%v, commit %v, built at %v", version, commit, date)
2017-04-21 15:25:32 -03: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",
},
}
app.Action = func(c *cli.Context) error {
log.Printf("Running goreleaser %v\n", version)
if err := goreleaserlib.Release(c); err != nil {
2017-04-21 15:25:32 -03: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 {
var filename = "goreleaser.yml"
err := goreleaserlib.InitProject(filename)
2017-04-27 11:03:26 +02:00
if err != nil {
return err
}
log.Printf("%s created. Please edit accordingly to your needs.", filename)
2017-04-27 11:03:26 +02:00
return nil
},
},
}
2017-04-21 15:25:32 -03:00
if err := app.Run(os.Args); err != nil {
log.Fatalln(err)
}
}