Skip to content

Commit

Permalink
use proto version data
Browse files Browse the repository at this point in the history
  • Loading branch information
Savid committed Oct 7, 2024
1 parent 58cedcb commit a12193c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ builds:
goarch:
- amd64
ldflags:
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.release={{.Tag}} -X github.com/ethpandaops/xatu/cmd.commit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.platform={{.Runtime.Goos}}/{{.Runtime.Goarch}}
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOOS={{.Runtime.Goos}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOARCH={{.Runtime.Goarch}}
mod_timestamp: "{{ .CommitTimestamp }}"

- id: linux-arm64
Expand All @@ -30,7 +30,7 @@ builds:
goarch:
- arm64
ldflags:
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.release={{.Tag}} -X github.com/ethpandaops/xatu/cmd.commit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.platform={{.Runtime.Goos}}/{{.Runtime.Goarch}}
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOOS={{.Runtime.Goos}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOARCH={{.Runtime.Goarch}}
mod_timestamp: "{{ .CommitTimestamp }}"

- id: windows-amd64
Expand All @@ -44,7 +44,7 @@ builds:
goarch:
- amd64
ldflags:
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.release={{.Tag}} -X github.com/ethpandaops/xatu/cmd.commit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.platform={{.Runtime.Goos}}/{{.Runtime.Goarch}}
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOOS={{.Runtime.Goos}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOARCH={{.Runtime.Goarch}}
mod_timestamp: "{{ .CommitTimestamp }}"

- id: darwin-amd64
Expand All @@ -58,7 +58,7 @@ builds:
goarch:
- amd64
ldflags:
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.release={{.Tag}} -X github.com/ethpandaops/xatu/cmd.commit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.platform={{.Runtime.Goos}}/{{.Runtime.Goarch}}
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOOS={{.Runtime.Goos}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOARCH={{.Runtime.Goarch}}
mod_timestamp: "{{ .CommitTimestamp }}"

- id: darwin-arm64
Expand All @@ -72,7 +72,7 @@ builds:
goarch:
- arm64
ldflags:
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.release={{.Tag}} -X github.com/ethpandaops/xatu/cmd.commit={{.ShortCommit}} -X github.com/ethpandaops/xatu/cmd.platform={{.Runtime.Goos}}/{{.Runtime.Goarch}}
- -s -w -X github.com/ethpandaops/xatu/pkg/proto/xatu.Release={{.Tag}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GitCommit={{.ShortCommit}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOOS={{.Runtime.Goos}} -X github.com/ethpandaops/xatu/pkg/proto/xatu.GOARCH={{.Runtime.Goarch}}
mod_timestamp: "{{ .CommitTimestamp }}"
checksum:
name_template: 'checksums.txt'
Expand Down
9 changes: 2 additions & 7 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ package cmd
import (
"fmt"

"github.com/ethpandaops/xatu/pkg/proto/xatu"
"github.com/spf13/cobra"
)

var (
release = "dev"
commit = "unknown"
platform = "unknown"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Prints the version of Xatu.",
Long: `Prints the version of Xatu.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("xatu version %s %s %s\n", release, commit, platform)
fmt.Printf("xatu version %s %s %s/%s\n", xatu.Release, xatu.GitCommit, xatu.GOOS, xatu.GOARCH)
},
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/proto/xatu/xatu.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var (
Release = "dev"
GitCommit = "dev"
Implementation = "Xatu"
GOOS = runtime.GOOS
GOARCH = runtime.GOARCH
)

func Full() string {
Expand All @@ -29,7 +31,7 @@ func Short() string {
}

func FullVWithGOOS() string {
return fmt.Sprintf("%s/%s", Full(), runtime.GOOS)
return fmt.Sprintf("%s/%s", Full(), GOOS)
}

func ImplementationLower() string {
Expand Down

0 comments on commit a12193c

Please sign in to comment.