Skip to content

Commit 237d01b

Browse files
committed
Print release tag in hugo version
Fixes #506
1 parent 0a957c5 commit 237d01b

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

hugoreleaser.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ archive_alias_replacements = {}
2626
binary = "s3deploy"
2727
flags = ["-buildmode", "exe"]
2828
env = ["CGO_ENABLED=0"]
29-
ldflags = ""
29+
ldflags = "-s -w -X main.tag=${HUGORELEASER_TAG}"
3030

3131
# Archive settings can be set on any of Project > Archive.
3232
# Follows the same merge rules as Build settings.

main.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
)
1616

1717
var (
18-
version = "v2"
19-
commit = "none"
20-
date = "unknown"
18+
commit = "none"
19+
tag = "(devel)"
20+
date = "unknown"
2121
)
2222

2323
func main() {
@@ -37,7 +37,7 @@ func parseAndRun(args []string) error {
3737
initVersionInfo()
3838

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

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

6161
return nil
62-
6362
}
6463

6564
func initVersionInfo() {
66-
if commit != "none" {
67-
// Set by goreleaser.
68-
return
69-
}
70-
7165
bi, ok := debug.ReadBuildInfo()
7266
if !ok {
7367
return
7468
}
7569

76-
version = bi.Main.Version
77-
7870
for _, s := range bi.Settings {
7971
switch s.Key {
8072
case "vcs":
@@ -85,5 +77,4 @@ func initVersionInfo() {
8577
case "vcs.modified":
8678
}
8779
}
88-
8980
}

0 commit comments

Comments
 (0)