mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-27 01:33:39 +02:00
ec2db4a727
<!-- Hi, thanks for contributing! Please make sure you read our CONTRIBUTING guide. Also, add tests and the respective documentation changes as well. --> <!-- If applied, this commit will... --> ... <!-- Why is this change being made? --> ... <!-- # Provide links to any relevant tickets, URLs or other resources --> ... --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
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
|
|
}
|
|
},
|
|
)
|
|
}
|