Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vt version doesn't print the version number #59

Closed
melomac opened this issue Feb 4, 2023 · 4 comments
Closed

vt version doesn't print the version number #59

melomac opened this issue Feb 4, 2023 · 4 comments

Comments

@melomac
Copy link

melomac commented Feb 4, 2023

I wanted to check my current vt CLI version (Homebrew) and was surprised to see vt version didn't print any version number.

So I checked out the repo to find out this is a current problem:

$ make
$ make install
$ ~/go/bin/vt version
vt-cli 

And I verified on an old setup, this isn't a regression as of commit 031203cad77b.

@melomac
Copy link
Author

melomac commented Feb 4, 2023

This looks like VERSION isn't set by defaults. On setting VERSION manually, this does work:

vt-cli (master)> make clean
rm -rf ./build

vt-cli (master)> env VERSION=test make
go build -ldflags "-X github.com/VirusTotal/vt-cli/cmd.Version=test" -o ./build/vt ./vt/main.go

vt-cli (master)> ./build/vt version
vt-cli test

Builds attached to this page prints the version number correctly.

Would you please consider a way to setup VERSION on manual build? ex: closest tag dash closest commit

@melomac
Copy link
Author

melomac commented Feb 4, 2023

May be something like this:

diff --git a/Makefile b/Makefile
index 9e76939..a8c9c3a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,15 @@
 # This how we want to name the binary output
 BINARY=./build/vt
 
+COMMIT := $(shell git rev-parse --short HEAD)
+TAG := $(shell git describe --tags $(COMMIT))
+ifneq ($(shell git status --porcelain),)
+    COMMIT := dirty
+endif
+ifeq ($(VERSION),)
+    VERSION := $(TAG)-$(COMMIT)
+endif
+
 # Setup the -ldflags option for go build here, interpolate the variable values
 LDFLAGS=-ldflags "-X github.com/VirusTotal/vt-cli/cmd.Version=${VERSION}"
 

@mgmacias95
Copy link
Member

I tried downloading one of the binaries from our release downloads page (https://github.com/VirusTotal/vt-cli/releases/tag/0.10.4) and it worked:

$ ./vt version
vt-cli 0.10.4

The version is set in our release pipeline:

- name: Build
run: make all
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
- name: Create release
run: ./new_release.sh
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}

@mgmacias95
Copy link
Member

Probably it's the homebrew formula which needs to be fixed? https://github.com/Homebrew/homebrew-core/blob/master/Formula/virustotal-cli.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants