Skip to content

Commit 3dc10e0

Browse files
committed
Makefile for release
1 parent f7560b4 commit 3dc10e0

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ _testmain.go
2222
*.exe
2323
*.test
2424
*.prof
25+
26+
dist/

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
VERSION := v0.1.0
2+
BUILDSTRING := $(shell git log --pretty=format:'%h' -n 1)
3+
VERSIONSTRING := tlsh version $(VERSION)+$(BUILDSTRING)
4+
BUILDDATE := $(shell date -u -Iseconds)
5+
6+
clean:
7+
rm -rf dist/
8+
9+
LDFLAGS := "-X \"main.VERSION=$(VERSIONSTRING)\" -X \"main.BUILDDATE=$(BUILDDATE)\""
10+
11+
.PHONY: build_release
12+
build_release: clean
13+
cd app; gox -arch="amd64" -os="windows darwin linux" -output="../dist/tlsh-{{.Arch}}-{{.OS}}" -ldflags=$(LDFLAGS)

app/tlsh.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@ import (
88
"github.com/glaslos/tlsh"
99
)
1010

11+
var (
12+
// VERSION is set by the makefile
13+
VERSION = "v0.0.0"
14+
// BUILDDATE is set by the makefile
15+
BUILDDATE = ""
16+
)
17+
1118
func main() {
1219
var file = flag.String("f", "", "path to the file to be hashed")
1320
var raw = flag.Bool("r", false, "set to get only the hash")
21+
var version = flag.Bool("version", false, "print version")
1422
flag.Parse()
23+
if *version {
24+
fmt.Printf("%s %s\n", VERSION, BUILDDATE)
25+
return
26+
}
1527
if *file == "" {
1628
fmt.Fprintf(os.Stderr, "Usage of %s [-f <file>]\n\n", os.Args[0])
1729
flag.PrintDefaults()

0 commit comments

Comments
 (0)