2017-04-21 20:25:32 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-22 02:58:59 +02:00
|
|
|
"fmt"
|
2017-04-21 20:25:32 +02:00
|
|
|
"os"
|
2021-03-31 02:06:25 +02:00
|
|
|
"runtime/debug"
|
2017-04-21 20:25:32 +02:00
|
|
|
|
2020-04-28 02:42:44 +02:00
|
|
|
"github.com/goreleaser/goreleaser/cmd"
|
2017-04-21 20:25:32 +02:00
|
|
|
)
|
|
|
|
|
2018-11-08 02:04:49 +02:00
|
|
|
// nolint: gochecknoglobals
|
2017-04-21 20:25:32 +02:00
|
|
|
var (
|
|
|
|
version = "dev"
|
2019-05-28 04:59:33 +02:00
|
|
|
commit = ""
|
|
|
|
date = ""
|
|
|
|
builtBy = ""
|
2017-04-21 20:25:32 +02:00
|
|
|
)
|
|
|
|
|
2018-11-08 02:04:49 +02:00
|
|
|
func main() {
|
2020-04-28 02:42:44 +02:00
|
|
|
cmd.Execute(
|
|
|
|
buildVersion(version, commit, date, builtBy),
|
|
|
|
os.Exit,
|
|
|
|
os.Args[1:],
|
|
|
|
)
|
2018-02-22 01:04:22 +02:00
|
|
|
}
|
2019-05-28 04:59:33 +02:00
|
|
|
|
2021-07-24 05:27:20 +02:00
|
|
|
const website = "\n\nhttps://goreleaser.com"
|
|
|
|
|
2019-05-28 04:59:33 +02:00
|
|
|
func buildVersion(version, commit, date, builtBy string) string {
|
2021-03-01 19:45:06 +02:00
|
|
|
result := version
|
2019-05-28 04:59:33 +02: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-31 02:06:25 +02: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 05:27:20 +02:00
|
|
|
return result + website
|
2019-05-28 04:59:33 +02:00
|
|
|
}
|