forked from goreleaser/goreleaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
72 lines (63 loc) · 1.48 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
package main
import (
"os"
_ "embed"
goversion "github.com/caarlos0/go-version"
"github.com/caarlos0/log"
"github.com/charmbracelet/lipgloss"
"github.com/goreleaser/goreleaser/v2/cmd"
"github.com/muesli/termenv"
"go.uber.org/automaxprocs/maxprocs"
)
//nolint:gochecknoglobals
var (
version = ""
commit = ""
treeState = ""
date = ""
builtBy = ""
)
func init() {
// enable colored output on github actions et al
if os.Getenv("CI") != "" {
lipgloss.SetColorProfile(termenv.TrueColor)
}
// automatically set GOMAXPROCS to match available CPUs.
// GOMAXPROCS will be used as the default value for the --parallelism flag.
if _, err := maxprocs.Set(); err != nil {
log.WithError(err).Warn("failed to set GOMAXPROCS")
}
}
func main() {
cmd.Execute(
buildVersion(version, commit, date, builtBy, treeState),
os.Exit,
os.Args[1:],
)
}
const website = "https://goreleaser.com"
//go:embed art.txt
var asciiArt string
func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info {
return goversion.GetVersionInfo(
goversion.WithAppDetails("goreleaser", "Deliver Go Binaries as fast and easily as possible", website),
goversion.WithASCIIName(asciiArt),
func(i *goversion.Info) {
if commit != "" {
i.GitCommit = commit
}
if treeState != "" {
i.GitTreeState = treeState
}
if date != "" {
i.BuildDate = date
}
if version != "" {
i.GitVersion = version
}
if builtBy != "" {
i.BuiltBy = builtBy
}
},
)
}