2017-04-21 15:25:32 -03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-21 21:58:59 -03:00
|
|
|
"fmt"
|
2017-04-21 15:25:32 -03:00
|
|
|
"os"
|
2021-12-17 16:39:55 -03:00
|
|
|
"runtime"
|
2021-03-30 21:06:25 -03:00
|
|
|
"runtime/debug"
|
2017-04-21 15:25:32 -03:00
|
|
|
|
2022-08-08 09:26:09 -03:00
|
|
|
"github.com/charmbracelet/lipgloss"
|
2020-04-27 21:42:44 -03:00
|
|
|
"github.com/goreleaser/goreleaser/cmd"
|
2022-08-08 09:26:09 -03:00
|
|
|
"github.com/muesli/termenv"
|
2017-04-21 15:25:32 -03:00
|
|
|
)
|
|
|
|
|
2018-11-07 22:04:49 -02:00
|
|
|
// nolint: gochecknoglobals
|
2017-04-21 15:25:32 -03:00
|
|
|
var (
|
|
|
|
version = "dev"
|
2019-05-27 23:59:33 -03:00
|
|
|
commit = ""
|
|
|
|
date = ""
|
|
|
|
builtBy = ""
|
2017-04-21 15:25:32 -03:00
|
|
|
)
|
|
|
|
|
2022-08-08 09:26:09 -03:00
|
|
|
func init() {
|
|
|
|
// enable colored output on github actions et al
|
|
|
|
if os.Getenv("CI") != "" {
|
|
|
|
lipgloss.SetColorProfile(termenv.TrueColor)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-07 22:04:49 -02:00
|
|
|
func main() {
|
2020-04-27 21:42:44 -03:00
|
|
|
cmd.Execute(
|
|
|
|
buildVersion(version, commit, date, builtBy),
|
|
|
|
os.Exit,
|
|
|
|
os.Args[1:],
|
|
|
|
)
|
2018-02-21 20:04:22 -03:00
|
|
|
}
|
2019-05-27 23:59:33 -03:00
|
|
|
|
2021-07-24 00:27:20 -03:00
|
|
|
const website = "\n\nhttps://goreleaser.com"
|
|
|
|
|
2019-05-27 23:59:33 -03:00
|
|
|
func buildVersion(version, commit, date, builtBy string) string {
|
2021-03-01 14:45:06 -03:00
|
|
|
result := version
|
2019-05-27 23:59:33 -03:00
|
|
|
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)
|
|
|
|
}
|
2021-12-17 16:39:55 -03:00
|
|
|
result = fmt.Sprintf("%s\ngoos: %s\ngoarch: %s", result, runtime.GOOS, runtime.GOARCH)
|
2021-03-30 21:06:25 -03:00
|
|
|
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)
|
|
|
|
}
|
2021-07-24 00:27:20 -03:00
|
|
|
return result + website
|
2019-05-27 23:59:33 -03:00
|
|
|
}
|