mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
6afe717dc9
This might fail on windows/wsl (see https://github.com/uber-go/automaxprocs/issues/65), and its not too bad if it fails, actually, so, let's just warn the error instead of exiting 1 closes #3945 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
64 lines
1.5 KiB
Go
64 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"runtime"
|
|
"runtime/debug"
|
|
|
|
"github.com/caarlos0/log"
|
|
"github.com/charmbracelet/lipgloss"
|
|
"github.com/goreleaser/goreleaser/cmd"
|
|
"github.com/muesli/termenv"
|
|
"go.uber.org/automaxprocs/maxprocs"
|
|
)
|
|
|
|
// nolint: gochecknoglobals
|
|
var (
|
|
version = "dev"
|
|
commit = ""
|
|
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 {
|
|
// might fail on WSL...
|
|
log.WithError(err).Warn("failed to set GOMAXPROCS")
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
cmd.Execute(
|
|
buildVersion(version, commit, date, builtBy),
|
|
os.Exit,
|
|
os.Args[1:],
|
|
)
|
|
}
|
|
|
|
const website = "\n\nhttps://goreleaser.com"
|
|
|
|
func buildVersion(version, commit, date, builtBy string) string {
|
|
result := version
|
|
if commit != "" {
|
|
result = fmt.Sprintf("%s\ncommit: %s", result, commit)
|
|
}
|
|
if date != "" {
|
|
result = fmt.Sprintf("%s\nbuilt at: %s", result, date)
|
|
}
|
|
if builtBy != "" {
|
|
result = fmt.Sprintf("%s\nbuilt by: %s", result, builtBy)
|
|
}
|
|
result = fmt.Sprintf("%s\ngoos: %s\ngoarch: %s", result, runtime.GOOS, runtime.GOARCH)
|
|
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {
|
|
result = fmt.Sprintf("%s\nmodule version: %s, checksum: %s", result, info.Main.Version, info.Main.Sum)
|
|
}
|
|
return result + website
|
|
}
|