Skip to content

Commit

Permalink
Print release tag in hugo version
Browse files Browse the repository at this point in the history
Fixes #506
  • Loading branch information
bep committed Oct 18, 2024
1 parent 0a957c5 commit 237d01b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
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":
}
}

}

0 comments on commit 237d01b

Please sign in to comment.