1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-29 01:44:39 +02:00
goreleaser/main.go
Carlos A Becker fcc1856590
feat(deps): update caarlos0/log
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
2022-08-08 09:26:09 -03:00

56 lines
1.2 KiB
Go

package main
import (
"fmt"
"os"
"runtime"
"runtime/debug"
"github.com/charmbracelet/lipgloss"
"github.com/goreleaser/goreleaser/cmd"
"github.com/muesli/termenv"
)
// 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)
}
}
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
}