-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: use goversion lib Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: trailing empty line Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
53 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
_____ ____ __ __ | ||
_ __ | ___| _ \| \/ | | ||
| '_ \| |_ | |_) | |\/| | | ||
| | | | _| | __/| | | | | ||
|_| |_|_| |_| |_| |_| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime/debug" | ||
|
||
_ "embed" | ||
|
||
goversion "github.com/caarlos0/go-version" | ||
"github.com/goreleaser/nfpm/v2/internal/cmd" | ||
) | ||
|
||
// nolint: gochecknoglobals | ||
var ( | ||
version = "dev" | ||
commit = "" | ||
date = "" | ||
builtBy = "" | ||
version = "dev" | ||
treeState = "" | ||
commit = "" | ||
date = "" | ||
builtBy = "" | ||
) | ||
|
||
const website = "https://nfpm.goreleaser.com" | ||
|
||
//go:embed art.txt | ||
var asciiArt string | ||
|
||
func main() { | ||
cmd.Execute( | ||
buildVersion(version, commit, date, builtBy), | ||
buildVersion(version, commit, date, builtBy, treeState), | ||
os.Exit, | ||
os.Args[1:], | ||
) | ||
} | ||
|
||
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) | ||
} | ||
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 | ||
func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info { | ||
return goversion.GetVersionInfo( | ||
goversion.WithAppDetails("nfpm", "a simple and 0-dependencies deb, rpm, apk and arch linux packager written in Go", website), | ||
goversion.WithASCIIName(asciiArt), | ||
func(i *goversion.Info) { | ||
if commit != "" { | ||
i.GitCommit = commit | ||
} | ||
if treeState != "" { | ||
i.GitTreeState = treeState | ||
} | ||
if date != "" { | ||
i.BuildDate = date | ||
} | ||
if version != "" { | ||
i.GitVersion = version | ||
} | ||
if builtBy != "" { | ||
i.BuiltBy = builtBy | ||
} | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters