Skip to content

Commit

Permalink
Add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
reshke committed Dec 25, 2023
1 parent 0ff9784 commit 181dec2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@

GIT_REVISION=`git rev-parse --short HEAD`
SPQR_VERSION=`git describe --tags --abbrev=0`
LDFLAGS=-ldflags "-X github.com/yezzey-gp/yproxy/pkg.GitRevision=${GIT_REVISION} -X github.com/yezzey-gp/yproxy/pkg.SpqrVersion=${SPQR_VERSION}"

####################### BUILD #######################

build:
mkdir -p devbin
go build -o devbin/yproxy ./cmd/yproxy
go build -pgo=auto -o devbin/yproxy $(LDFLAGS) ./cmd/yproxy
go build -o devbin/client ./cmd/client

####################### TESTS #######################
Expand Down
2 changes: 2 additions & 0 deletions cmd/yproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra"

"github.com/yezzey-gp/yproxy/config"
"github.com/yezzey-gp/yproxy/pkg"
"github.com/yezzey-gp/yproxy/pkg/core"
"github.com/yezzey-gp/yproxy/pkg/ylogger"
)
Expand Down Expand Up @@ -34,6 +35,7 @@ var rootCmd = &cobra.Command{

return instance.Run(instanceCnf)
},
Version: pkg.YproxyVersionRevision,
}

func init() {
Expand Down
10 changes: 10 additions & 0 deletions pkg/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package pkg

import "fmt"

var (
// These variables are here only to show current version. They are set in makefile during build process
SpqrVersion = "devel"
GitRevision = "devel"
YproxyVersionRevision = fmt.Sprintf("%s-%s", SpqrVersion, GitRevision)
)

0 comments on commit 181dec2

Please sign in to comment.