From 2d8d03bc22ce81487e51c22b9dd2ada573fb9cfa Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sun, 21 Feb 2016 11:06:40 +0100 Subject: [PATCH] Make the builds reproducable based on commit sha --- Makefile | 3 ++- main.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ffd60b2..0eab019 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,9 @@ EXECUTABLE ?= drone-github-release IMAGE ?= plugins/$(EXECUTABLE) +COMMIT ?= $(shell git rev-parse --short HEAD) -LDFLAGS = -X "main.buildDate=$(shell date -u '+%Y-%m-%d %H:%M:%S %Z')" +LDFLAGS = -X "main.buildCommit=$(COMMIT)" PACKAGES = $(shell go list ./... | grep -v /vendor/) all: deps build test diff --git a/main.go b/main.go index f7f1336..c5e8522 100644 --- a/main.go +++ b/main.go @@ -15,11 +15,11 @@ import ( ) var ( - buildDate string + buildCommit string ) func main() { - fmt.Printf("Drone GitHub Release Plugin built at %s\n", buildDate) + fmt.Printf("Drone GitHub Release Plugin built from %s\n", buildCommit) workspace := drone.Workspace{} repo := drone.Repo{}