Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ WATCHER_NAME=watcher

HOST_OS=$(shell go env GOOS)
HOST_ARCH=$(shell go env GOARCH)
GO ?= go
BUILD_FLAGS ?=
VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || echo unknown)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
LDFLAGS=-X ${PACKAGE}/version.Version=${VERSION} -X ${PACKAGE}/version.Commit=${COMMIT}

.PHONY: build-local
build-local:
go build -o ${DIST_DIR}/${BIN_NAME}
$(GO) build $(BUILD_FLAGS) -ldflags "${LDFLAGS}" -o ${DIST_DIR}/${BIN_NAME}

.PHONY: clean
clean:
Expand All @@ -25,6 +30,12 @@ build-binaries:
make BIN_NAME=${CLI_NAME}-windows-amd64.exe GOOS=windows build-local
make BIN_NAME=${CLI_NAME}-windows-386.exe GOOS=windows GOARCH=386 build-local

.PHONY: build-release
build-release:
$(eval RELEASE_VERSION := $(shell git describe --tags --exact-match 2>/dev/null))
@test -n "${RELEASE_VERSION}" || (echo "build-release must be run from a git tag" && exit 1)
make VERSION=${RELEASE_VERSION} build-binaries

.PHONY: build-watcher
build-watcher:
go build -o ${DIST_DIR}/${BIN_NAME}-${WATCHER_NAME} ${PACKAGE}/watcher
$(GO) build $(BUILD_FLAGS) -o ${DIST_DIR}/${BIN_NAME}-${WATCHER_NAME} ${PACKAGE}/watcher
3 changes: 3 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/microcks/microcks-cli/pkg/config"
"github.com/microcks/microcks-cli/pkg/connectors"
"github.com/microcks/microcks-cli/pkg/errors"
"github.com/microcks/microcks-cli/version"
"github.com/spf13/cobra"
)

Expand All @@ -29,6 +30,7 @@ func NewCommad() *cobra.Command {
command := &cobra.Command{
Use: "microcks",
Short: "A CLI tool for Microcks",
Version: version.Info(),
SilenceUsage: true,
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
Expand All @@ -37,6 +39,7 @@ func NewCommad() *cobra.Command {
HiddenDefaultCmd: true,
},
}
command.SetVersionTemplate("{{.Version}}\n")

command.AddCommand(NewImportCommand(&clientOpts))
command.AddCommand(NewImportDirCommand(&clientOpts))
Expand Down
6 changes: 3 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
func NewVersionCommand() *cobra.Command {
var command = &cobra.Command{
Use: "version",
Short: "Print the version number of microcks CLI",
Long: `Print the version number of microcks CLI`,
Short: "Print the version number of Microcks CLI",
Long: `Print the version number of Microcks CLI`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Microcks-CLI %s\n", version.Version)
fmt.Println(version.Info())
},
}

Expand Down
7 changes: 6 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
package version

var (
Version = "1.0.3"
Version = "unknown"
Commit = "unknown"
)

func Info() string {
return "Microcks CLI " + Version + "\nCommit: " + Commit
}