Skip to content

Commit

Permalink
Replace version by git tag or commit hash if not manually specified
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsheep committed Feb 3, 2022
1 parent cc9dc96 commit 0a6d441
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
15 changes: 3 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
VERSION ?= $$(git describe --tags 2>/dev/null || git rev-parse --short HEAD)
LEVEL ?= release
OUTPUT ?= sshs

GO_PACKAGE_PATH := github.com/quantumsheep/sshs
VERSION := $$(git describe --tags 2>/dev/null || true)
BUILD := $$(git rev-parse --short HEAD)

ifeq ($(VERSION),)
VERSION := latest
endif

ifeq ($(BUILD),)
BUILD := dev
endif

ifeq ($(LEVEL),release)
GOLDFLAGS := -w -s
GOLDFLAGS := -w -s
endif

build:
go build -ldflags "$(GOLDFLAGS) -X '$(GO_PACKAGE_PATH)/cmd.Version=$(VERSION)' -X '$(GO_PACKAGE_PATH)/cmd.Build=$(BUILD)'" -o $(OUTPUT)
go build -ldflags "$(GOLDFLAGS) -X '$(GO_PACKAGE_PATH)/cmd.Version=$(or $(strip $(VERSION)),latest)'" -o $(OUTPUT)

clean:
rm -f sshs
Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ func connect(name string) {

var (
Version string
Build string
)

var rootCmd = &cobra.Command{
Use: "sshs",
Short: "ssh clients manager",
Version: fmt.Sprintf("%s, build %s", Version, Build),
Version: Version,
Run: func(cmd *cobra.Command, args []string) {
filepath, e := homedir.Expand("~/.ssh/config")
if e != nil {
Expand Down

0 comments on commit 0a6d441

Please sign in to comment.