File tree Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ builds:
19
19
ldflags :
20
20
# use commit date instead of current date as main.date
21
21
# only needed if you actually use those things in your main package, otherwise can be ignored.
22
- - -s -w -X main.version ={{.Version}} -X main.commit ={{.Commit}} -X main.date ={{ .CommitDate }}
22
+ - -s -w -X github.com/grepplabs/reverse-http/config.Version ={{.Version}} -X github.com/grepplabs/reverse-http/config.Commit ={{.Commit}} -X github.com/grepplabs/reverse-http/config.Date ={{ .CommitDate }}
23
23
24
24
# proxies from the go mod proxy before building
25
25
# https://goreleaser.com/customization/gomod
Original file line number Diff line number Diff line change 5
5
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
6
6
7
7
BUILD_FLAGS ?=
8
- VERSION = "0.0.1 "
8
+ VERSION = "develop "
9
9
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
10
10
REVISION = $(shell git describe --tags --always --dirty)
11
11
BUILD_DATE = $(shell date +'% Y.% m.% d-% H:% M:% S')
12
- LDFLAGS ?= -w -s
12
+ LDFLAGS ?= -w -s \
13
+ -X github.com/grepplabs/reverse-http/config.Version=${VERSION} \
14
+ -X github.com/grepplabs/reverse-http/config.Commit=${REVISION} \
15
+ -X github.com/grepplabs/reverse-http/config.Date=${BUILD_DATE}
16
+
13
17
BINARY = reverse-http
14
18
15
19
TEST_AGENT_ID = 4711
Original file line number Diff line number Diff line change 1
1
package cmd
2
2
3
3
import (
4
+ "encoding/json"
4
5
"fmt"
5
6
"os"
6
7
@@ -20,6 +21,9 @@ type CLI struct {
20
21
Proxy config.ProxyCmd `name:"proxy" cmd:"" help:"Start proxy server."`
21
22
LoadBalancer config.LoadBalancerCmd `name:"lb" cmd:"" help:"Start load balancer."`
22
23
Auth config.AuthCmd `name:"auth" cmd:"" help:"auth tools."`
24
+ Version struct {
25
+ Verbose bool `short:"V" help:"Verbose."`
26
+ } `name:"version" cmd:"" help:"Show version"`
23
27
}
24
28
25
29
func Execute () {
@@ -51,6 +55,16 @@ func Execute() {
51
55
case "auth jwt token" :
52
56
err := runAuthJwtToken (& cli .Auth .JwtCmd .TokenCmd )
53
57
ctx .FatalIfErrorf (err )
58
+ case "version" :
59
+ if cli .Version .Verbose {
60
+ _ = json .NewEncoder (os .Stdout ).Encode (map [string ]any {
61
+ "version" : config .Version ,
62
+ "commit" : config .Commit ,
63
+ "date" : config .Date ,
64
+ })
65
+ } else {
66
+ fmt .Println (config .Version )
67
+ }
54
68
default :
55
69
fmt .Println (ctx .Command ())
56
70
os .Exit (1 )
Original file line number Diff line number Diff line change
1
+ package config
2
+
3
+ var (
4
+ Version = "dev"
5
+ Commit = "none"
6
+ Date = "unknown"
7
+ )
You can’t perform that action at this time.
0 commit comments