From 22f143de4fae774dde03d9818de290a89fa8e985 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sun, 21 Feb 2016 11:06:39 +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 3610e45..3881d6f 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,9 @@ EXECUTABLE ?= drone-docker 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 c29ef5b..cc4957e 100644 --- a/main.go +++ b/main.go @@ -41,11 +41,11 @@ type Docker struct { } var ( - buildDate string + buildCommit string ) func main() { - fmt.Printf("Drone Docker Plugin built at %s\n", buildDate) + fmt.Printf("Drone Docker Plugin built from %s\n", buildCommit) workspace := plugin.Workspace{} build := plugin.Build{}