Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: price-feeder version #1291

Merged
merged 11 commits into from
Aug 30, 2022
1 change: 1 addition & 0 deletions price-feeder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1264](https://github.com/umee-network/umee/pull/1264) Convert osmosis candle timestamp from seconds to milliseconds.
- [1262](https://github.com/umee-network/umee/pull/1262) Add verification for quote in tvwap map.
- [1268](https://github.com/umee-network/umee/pull/1268) Don't panic when a provider has only out-of-date candles.
- [1291](https://github.com/umee-network/umee/pull/1291) Set sdk version during build time.

### Improvements

Expand Down
5 changes: 4 additions & 1 deletion price-feeder/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
BUILD_DIR ?= $(CURDIR)/build
COMMIT := $(shell git log -1 --format='%H')
SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')

all: test-unit install

Expand All @@ -22,7 +24,8 @@ endif
###############################################################################

ldflags = -X github.com/umee-network/umee/price-feeder/cmd.Version=$(VERSION) \
-X github.com/umee-network/umee/price-feeder/cmd.Commit=$(COMMIT)
-X github.com/umee-network/umee/price-feeder/cmd.Commit=$(COMMIT) \
-X github.com/umee-network/umee/price-feeder/cmd.SDKVersion=$(SDK_VERSION)

BUILD_FLAGS := -ldflags '$(ldflags)'

Expand Down
20 changes: 5 additions & 15 deletions price-feeder/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ package cmd
import (
"encoding/json"
"fmt"
"os"
"runtime"

"github.com/sirkon/goproxy/gomod"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)

const (
flagFormat = "format"

pathCosmosSDK = "github.com/cosmos/cosmos-sdk"
)

var (
Expand All @@ -24,6 +20,9 @@ var (
// Commit defines the application commit hash (defined at compile time)
Commit = ""

// SDKVersion defines the sdk version (defined at compile time)
SDKVersion = ""

versionFormat string
)

Expand All @@ -39,25 +38,16 @@ func getVersionCmd() *cobra.Command {
Use: "version",
Short: "Print binary version information",
RunE: func(cmd *cobra.Command, args []string) error {
modBz, err := os.ReadFile("go.mod")
if err != nil {
return err
}

mod, err := gomod.Parse("go.mod", modBz)
if err != nil {
return err
}

verInfo := versionInfo{
Version: Version,
Commit: Commit,
SDK: mod.Require[pathCosmosSDK],
SDK: SDKVersion,
Go: fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH),
}

var bz []byte

var err error
switch versionFormat {
case "json":
bz, err = json.Marshal(verInfo)
Expand Down