Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Apr 26, 2020
1 parent 235f355 commit 7eacca2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 32 deletions.
44 changes: 21 additions & 23 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
---
archives:
-
replacements:
386: i386
amd64: x86_64
darwin: Darwin
linux: Linux
windows: Windows
before:
hooks:
# you may remove this if you don't use vgo
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
- "go mod download"
- "go generate ./..."
builds:
- env:
- CGO_ENABLED=0
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
ldflags:
- -s -w -X cmd.version={{.Version}} -X cmd.commit={{.Commit}} -X cmd.date={{.Date}} -X cmd.builtBy=goreleaser
- ./usemsan=-msan
-
env:
- CGO_ENABLED=0
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"
sort: asc
checksum:
name_template: checksums.txt
snapshot:
name_template: "{{ .Tag }}-next"
9 changes: 8 additions & 1 deletion beetle.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import (
"github.com/clivern/beetle/internal/app/cmd"
)

var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)

func main() {
cmd.Execute()
cmd.Execute(version, commit, date, builtBy)
}
15 changes: 14 additions & 1 deletion internal/app/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
"github.com/spf13/cobra"
)

var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)

var rootCmd = &cobra.Command{
Use: "beetle",
Short: `Work seamlessly with Beetle from the command line.
Expand All @@ -20,7 +27,13 @@ feedback at <https://github.com/Clivern/Beetle>`,
}

// Execute runs cmd tool
func Execute() {
func Execute(version, commit, date, builtBy string) {
// Move build ldflags to cmd pkg
version = version
commit = commit
date = date
builtBy = builtBy

if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
7 changes: 0 additions & 7 deletions internal/app/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import (
"github.com/spf13/cobra"
)

var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Get current and latest version",
Expand Down

0 comments on commit 7eacca2

Please sign in to comment.