Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print release tag in version #507

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hugoreleaser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ archive_alias_replacements = {}
binary = "s3deploy"
flags = ["-buildmode", "exe"]
env = ["CGO_ENABLED=0"]
ldflags = ""
ldflags = "-s -w -X main.tag=${HUGORELEASER_TAG}"

# Archive settings can be set on any of Project > Archive.
# Follows the same merge rules as Build settings.
Expand Down
17 changes: 4 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
)

var (
version = "v2"
commit = "none"
date = "unknown"
commit = "none"
tag = "(devel)"
date = "unknown"
)

func main() {
Expand All @@ -37,7 +37,7 @@ func parseAndRun(args []string) error {
initVersionInfo()

if !cfg.Silent {
fmt.Printf("s3deploy %v, commit %v, built at %v\n", version, commit, date)
fmt.Printf("s3deploy %v, commit %v, built at %v\n", tag, commit, date)
}

if cfg.Help {
Expand All @@ -59,22 +59,14 @@ func parseAndRun(args []string) error {
}

return nil

}

func initVersionInfo() {
if commit != "none" {
// Set by goreleaser.
return
}

bi, ok := debug.ReadBuildInfo()
if !ok {
return
}

version = bi.Main.Version

for _, s := range bi.Settings {
switch s.Key {
case "vcs":
Expand All @@ -85,5 +77,4 @@ func initVersionInfo() {
case "vcs.modified":
}
}

}
Loading