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-03-30 21:06:25 -03:00
|
|
|
"runtime/debug"
|
2017-04-21 15:25:32 -03:00
|
|
|
|
2020-04-27 21:42:44 -03:00
|
|
|
"github.com/goreleaser/goreleaser/cmd"
|
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
|
|
|
)
|
|
|
|
|
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
|
|
|
|
|
|
|
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-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)
|
|
|
|
}
|
2019-05-27 23:59:33 -03:00
|
|
|
return result
|
|
|
|
}
|