Skip to content

Commit

Permalink
Use built version
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfus committed Mar 15, 2024
1 parent 046e540 commit f865a19
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/protoc-gen-bigquery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ import (
)

func main() {
protoplugin.Main(protoplugin.HandlerFunc(pluginbigquery.Handle), protoplugin.WithVersion(protoschema.Version))
protoplugin.Main(protoplugin.HandlerFunc(pluginbigquery.Handle), protoplugin.WithVersion(protoschema.Version()))
}
2 changes: 1 addition & 1 deletion cmd/protoc-gen-jsonschema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ import (
)

func main() {
protoplugin.Main(protoplugin.HandlerFunc(pluginjsonschema.Handle), protoplugin.WithVersion(protoschema.Version))
protoplugin.Main(protoplugin.HandlerFunc(pluginjsonschema.Handle), protoplugin.WithVersion(protoschema.Version()))
}
2 changes: 1 addition & 1 deletion cmd/protoc-gen-pubsub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ import (
)

func main() {
protoplugin.Main(protoplugin.HandlerFunc(pluginpubsub.Handle), protoplugin.WithVersion(protoschema.Version))
protoplugin.Main(protoplugin.HandlerFunc(pluginpubsub.Handle), protoplugin.WithVersion(protoschema.Version()))
}
14 changes: 11 additions & 3 deletions internal/protoschema/protoschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@

package protoschema

const (
// Version is the current version of protoschema which is shared by all plugins.
Version = "0.2.0-dev"
import (
"runtime/debug"
"strings"
)

func Version() string {
buildInfo, ok := debug.ReadBuildInfo()
if ok && buildInfo != nil && buildInfo.Main.Version != "" {
return strings.TrimSpace(buildInfo.Main.Version)
}
return "devel"
}

0 comments on commit f865a19

Please sign in to comment.