From fa8f31e8d3c4ba39f5d0410999bd3168478633c4 Mon Sep 17 00:00:00 2001 From: David Allen Date: Wed, 28 Aug 2024 13:18:14 -0600 Subject: [PATCH] Updated makefile to build with ldflags --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f8de63c..67168df 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,12 @@ ifndef VERSION $(error VERSION is not set. Please review and copy config.env.default to config.env and try again) endif +ifndef BUILD +$(error BUILD is not set. Please review and copy config.env.default to config.env and try again) +endif + +LDFLAGS="-s -X=$(GIT)main.commit=$(BUILD) -X=$(GIT)main.version=$(VERSION) -X=$(GIT)main.date=$(shell date +%Y-%m-%d:%H:%M:%S)" + SHELL := /bin/bash GOPATH ?= $(shell echo $${GOPATH:-~/go}) @@ -54,8 +60,8 @@ release: ## goreleaser build $(GOPATH)/bin/goreleaser build --clean --single-target --snapshot .PHONY: build -build: ## goreleaser build - go build --tags=all +build: ## go build + go build -v --tags=all -ldflags=$(LDFLAGS) -o $(NAME) main.go .PHONY: docker container: ## docker build