forked from goreleaser/goreleaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
93 lines (87 loc) · 2.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"fmt"
"os"
"github.com/apex/log"
lcli "github.com/apex/log/handlers/cli"
"github.com/goreleaser/goreleaser/goreleaserlib"
"github.com/urfave/cli"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func init() {
log.SetHandler(lcli.New(os.Stdout))
}
func main() {
var app = cli.NewApp()
app.Name = "goreleaser"
app.Version = fmt.Sprintf("%v, commit %v, built at %v", version, commit, date)
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",
},
cli.BoolFlag{
Name: "snapshot",
Usage: "Generate an unversioned snapshot release",
},
cli.BoolFlag{
Name: "rm-dist",
Usage: "Remove ./dist before building",
},
cli.IntFlag{
Name: "parallelism, p",
Usage: "Amount of builds launch in parallel",
Value: 4,
},
cli.BoolFlag{
Name: "debug",
Usage: "Enable debug mode",
},
}
app.Action = func(c *cli.Context) error {
log.Infof("running goreleaser %v", version)
if err := goreleaserlib.Release(c); err != nil {
log.WithError(err).Error("release failed")
return cli.NewExitError("\n", 1)
}
return nil
}
app.Commands = []cli.Command{
{
Name: "init",
Aliases: []string{"i"},
Usage: "generate .goreleaser.yml",
Action: func(c *cli.Context) error {
var filename = ".goreleaser.yml"
if err := goreleaserlib.InitProject(filename); err != nil {
log.WithError(err).Error("failed to init project")
return cli.NewExitError("\n", 1)
}
log.WithField("file", filename).
Info("config created; please edit accordingly to your needs")
return nil
},
},
}
if err := app.Run(os.Args); err != nil {
log.WithError(err).Fatal("failed")
}
}