Skip to content

Commit

Permalink
Add version info and use go-yaml patched version
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Dec 21, 2024
1 parent 0ae65e2 commit 289ff54
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
)

require (
github.com/goccy/go-yaml v1.15.11
github.com/goccy/go-yaml v1.15.13-0.20241221080047-87aec7d7f886
github.com/gohugoio/hugoreleaser-plugins-api v0.7.1-0.20241220094410-1f02562cf9b9
golang.org/x/sync v0.10.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/goccy/go-yaml v1.15.11 h1:XeEd/2INF0TXXWMzJ9ALqJLGjGDl4PIi1gmrK+7KpAs=
github.com/goccy/go-yaml v1.15.11/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/goccy/go-yaml v1.15.13-0.20241221080047-87aec7d7f886 h1:DGV2XraUpNBGuKdxYuNFmlm4feqfEFMm+48p2YUQnqw=
github.com/goccy/go-yaml v1.15.13-0.20241221080047-87aec7d7f886/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/gohugoio/hugoreleaser-plugins-api v0.7.1-0.20241220094410-1f02562cf9b9 h1:JT6XVa3wBdkwrgcV4EYku7fZOfLX2MjWgWWtHtp5IQs=
github.com/gohugoio/hugoreleaser-plugins-api v0.7.1-0.20241220094410-1f02562cf9b9/go.mod h1:Qheg3q6TF7pq9etJBNceTqGaM1VfkYDnm2k2KIIC/Ac=
github.com/gohugoio/hugoreleaser/plugins v0.1.1-0.20220822083757-38d81884db04 h1:VNOiFvTuhXc2eoDvBVQHsfxl1TTS2/EF1wFs1YttIlA=
Expand Down
2 changes: 1 addition & 1 deletion hugoreleaser.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Next release
HUGORELEASER_TAG=v0.59.0
HUGORELEASER_TAG=v0.60.0
HUGORELEASER_COMMITISH=main
2 changes: 1 addition & 1 deletion hugoreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build_settings:
- exe
env:
- CGO_ENABLED=0
ldflags: ""
ldflags: "-s -w -X main.tag=${HUGORELEASER_TAG}"

# This can be overridden for each archive.
archive_settings:
Expand Down
2 changes: 0 additions & 2 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,4 @@ func TestDecodeFile(t *testing.T) {
}
}
}

fmt.Println("===> FI", cfg.ReleaseSettings.ReleaseNotesSettings.Filename)
}
39 changes: 39 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ import (
"golang.org/x/sync/errgroup"
)

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

func main() {
log.SetFlags(0)

Expand Down Expand Up @@ -70,6 +76,7 @@ func parseAndRun(args []string) (err error) {
archiveCommand,
releaseCommand,
allCommand,
newVersionCommand(),
}

opts := []ff.Option{
Expand Down Expand Up @@ -157,3 +164,35 @@ func parseAndRun(args []string) (err error) {

return err
}

func newVersionCommand() *ffcli.Command {
return &ffcli.Command{
Name: "version",
ShortUsage: "hugoreleaser version",
ShortHelp: "Print the version",
LongHelp: "Print the version",
Exec: func(context.Context, []string) error {
initVersionInfo()
fmt.Printf("hugoreleaser %v, commit %v, built at %v\n", tag, commit, date)
return nil
},
}
}

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

for _, s := range bi.Settings {
switch s.Key {
case "vcs":
case "vcs.revision":
commit = s.Value
case "vcs.time":
date = s.Value
case "vcs.modified":
}
}
}

0 comments on commit 289ff54

Please sign in to comment.