Skip to content

Commit

Permalink
chore: add version command (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbreithecker authored Oct 30, 2024
1 parent 00bf173 commit ddc5af9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
COMMIT := $(shell git log -1 --format='%H')
VERSION := 0.2 # $(shell echo $(shell git describe --tags) | sed 's/^v//')
VERSION := 1.0.0 # $(shell echo $(shell git describe --tags) | sed 's/^v//')

ldflags = -X main.AppName=dlt \
-X main.Version=$(VERSION) \
-X main.Commit=$(COMMIT)
ldflags = -X github.com/KYVENetwork/KYVE-DLT/cmd/dlt/commands.Version=$(VERSION) \
-X github.com/KYVENetwork/KYVE-DLT/cmd/dlt/commands.Commit=$(COMMIT) \
-s \
-w

BUILD_FLAGS := -ldflags '$(ldflags)' -trimpath
BUILD_FLAGS := -ldflags '$(ldflags)' -trimpath -buildvcs=false

.PHONY: build format lint release

Expand All @@ -17,7 +18,7 @@ all: format lint build

build:
@echo "🤖 Building KYVE-DLT ..."
@go build $(BUILD_FLAGS) -o "$(PWD)/build/" ./cmd/dlt
@CGO_ENABLED=0 go build $(BUILD_FLAGS) -o "$(PWD)/build/" ./cmd/dlt
@echo "✅ Completed build!"

###############################################################################
Expand Down Expand Up @@ -47,5 +48,9 @@ release:
@tar -czf release/dlt_linux_arm64.tar.gz dlt
@shasum -a 256 release/dlt_linux_arm64.tar.gz >> release/release_checksum

@GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) ./cmd/dlt
@tar -czf release/dlt_linux_amd64.tar.gz dlt
@shasum -a 256 release/dlt_linux_amd64.tar.gz >> release/release_checksum

@rm dlt
@echo "✅ Completed release creation!"
25 changes: 25 additions & 0 deletions cmd/dlt/commands/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package commands

import (
"fmt"
"github.com/spf13/cobra"
)

var (
Version string
Commit string
)

func init() {
rootCmd.AddCommand(versionCmd)
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Show version and build information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("KYVE Data-Load-Tool (DLT)")
fmt.Printf("Version: %s\n", Version)
fmt.Printf("Commit: %s\n", Commit)
},
}

0 comments on commit ddc5af9

Please sign in to comment.