1
1
mirror of https://github.com/goreleaser/nfpm synced 2024-09-27 06:31:45 +02:00
nfpm/cmd/nfpm/main.go
2021-04-23 09:29:19 -03:00

43 lines
841 B
Go

package main
import (
"fmt"
"os"
"runtime/debug"
"github.com/goreleaser/nfpm/v2/internal/cmd"
)
// nolint: gochecknoglobals
var (
version = "dev"
commit = ""
date = ""
builtBy = ""
)
func main() {
cmd.Execute(
buildVersion(version, commit, date, builtBy),
os.Exit,
os.Args[1:],
)
}
func buildVersion(version, commit, date, builtBy string) string {
result := "nfpm version " + 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)
}
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
}