diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 71afd9de..40da917d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -24,6 +24,8 @@ builds: goarch: - amd64 - arm64 + ldflags: + - -s -w -X github.com/psviderski/uncloud/internal/version.version={{ .Version }} - id: uncloudd main: ./cmd/uncloudd @@ -35,6 +37,8 @@ builds: goarch: - amd64 - arm64 + ldflags: + - -s -w -X github.com/psviderski/uncloud/internal/version.version={{ .Version }} archives: - id: uncloud diff --git a/cmd/uncloud/main.go b/cmd/uncloud/main.go index 1add1cc0..9640eb9d 100644 --- a/cmd/uncloud/main.go +++ b/cmd/uncloud/main.go @@ -15,6 +15,7 @@ import ( "github.com/psviderski/uncloud/internal/cli" "github.com/psviderski/uncloud/internal/cli/config" "github.com/psviderski/uncloud/internal/fs" + "github.com/psviderski/uncloud/internal/version" "github.com/spf13/cobra" ) @@ -28,6 +29,7 @@ func main() { cmd := &cobra.Command{ Use: "uncloud", Short: "A CLI tool for managing Uncloud resources such as clusters, machines, and services.", + Version: version.String(), SilenceUsage: true, SilenceErrors: true, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 00000000..c05c1c24 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,7 @@ +package version + +var version string + +func String() string { + return version +}