From 2fac22702c209ac2b79ddc1bc53aa0157195eb46 Mon Sep 17 00:00:00 2001
From: Benjamin Bollen <ben@monax.io>
Date: Fri, 25 Nov 2016 18:57:02 +0100
Subject: [PATCH] make: add commit-sha to build targets

---
 .gitignore | 4 ++++
 Makefile   | 9 +++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index d2482dea..221e318e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,9 @@
 # do not vendor in dependencies
 vendor
+
+# build target
+target
+
 # Temporary / cached
 *.swp
 debug
diff --git a/Makefile b/Makefile
index c03b6034..b7f89cac 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ GOFILES_NOVENDOR := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
 PACKAGES_NOVENDOR := $(shell go list github.com/eris-ltd/eris-db/... | grep -v /vendor/)
 VERSION_MIN := $(shell cat ./version/version.go | tail -n 1 | cut -d \  -f 4 | tr -d '"')
 VERSION_MAJ := $(shell echo ${VERSION_MIN} | cut -d . -f 1-2)
+COMMIT_SHA := $(shell echo `git rev-parse --short --verify HEAD`)
 BUILD_DIR?=target
 
 .PHONY: greet
@@ -58,12 +59,12 @@ build_race:	build_race_db build_race_client build_race_keys
 # build eris-db
 .PHONY: build_db
 build_db:
-	go build -o ${BUILD_DIR}/eris-db ./cmd/eris-db
+	go build -o ${BUILD_DIR}/eris-db-${COMMIT_SHA} ./cmd/eris-db
 
 # build eris-client
 .PHONY: build_client
 build_client:
-	go build -o ${BUILD_DIR}/eris-client ./client/cmd/eris-client
+	go build -o ${BUILD_DIR}/eris-client-${COMMIT_SHA} ./client/cmd/eris-client
 
 # build eris-keys
 .PHONY: build_keys
@@ -73,12 +74,12 @@ build_keys:
 # build eris-db with checks for race conditions
 .PHONY: build_race_db
 build_race_db:
-	go build -race -o ${BUILD_DIR}/eris-db ./cmd/eris-db
+	go build -race -o ${BUILD_DIR}/eris-db-${COMMIT_SHA} ./cmd/eris-db
 
 # build eris-client with checks for race conditions
 .PHONY: build_race_client
 build_race_client:
-	go build -race -o ${BUILD_DIR}/eris-client ./client/cmd/eris-client
+	go build -race -o ${BUILD_DIR}/eris-client-${COMMIT_SHA} ./client/cmd/eris-client
 
 # build eris-keys with checks for race conditions
 .PHONY: build_race_keys
-- 
GitLab