diff --git a/.goreleaser.yml b/.goreleaser.yml index ea0b18f..184a2ea 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,6 +13,7 @@ builds: - arm64 binary: registrygen main: ./main.go + ldflags: -X github.com/pulumi/registrygen/pkg/version.Version={{.Version}} archives: - name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" format_overrides: diff --git a/cmd/root.go b/cmd/root.go index 59b6fed..65d9ddc 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,6 +5,7 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging" "github.com/pulumi/registrygen/cmd/docs" "github.com/pulumi/registrygen/cmd/metadata" + "github.com/pulumi/registrygen/cmd/version" "github.com/spf13/cobra" ) @@ -33,6 +34,7 @@ func RootCmd() *cobra.Command { rootCmd.AddCommand(docs.ResourceDocsCmd()) rootCmd.AddCommand(metadata.PackageMetadataCmd()) + rootCmd.AddCommand(version.Command()) return rootCmd } diff --git a/cmd/version/cli.go b/cmd/version/cli.go new file mode 100644 index 0000000..6c9f1f0 --- /dev/null +++ b/cmd/version/cli.go @@ -0,0 +1,21 @@ +package version + +import ( + "fmt" + + cliVersion "github.com/pulumi/registrygen/pkg/version" + "github.com/spf13/cobra" +) + +func Command() *cobra.Command { + command := &cobra.Command{ + Use: "version", + Short: "Get the current version", + Long: `Get the current version of pulumictl`, + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Println(cliVersion.Version) + return nil + }, + } + return command +} diff --git a/pkg/version/version.go b/pkg/version/version.go new file mode 100644 index 0000000..2e9506e --- /dev/null +++ b/pkg/version/version.go @@ -0,0 +1,4 @@ +package version + +// Version is the version of this tool. +var Version string