aboutsummaryrefslogtreecommitdiff
path: root/templates/go/Makefile
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2023-12-19 08:57:04 -0800
committerFranck Cuny <franck@fcuny.net>2023-12-19 08:58:54 -0800
commitb59565bf7460b1a487e8e4d9b92834e3fdeed418 (patch)
tree4d3c0d3d31f885dd0ab671a4b3029d7ace449065 /templates/go/Makefile
parentchore: update flake (diff)
downloadinfra-b59565bf7460b1a487e8e4d9b92834e3fdeed418.tar.gz
add goreleaser to go template
Diffstat (limited to 'templates/go/Makefile')
-rw-r--r--templates/go/Makefile19
1 files changed, 19 insertions, 0 deletions
diff --git a/templates/go/Makefile b/templates/go/Makefile
new file mode 100644
index 0000000..34fe639
--- /dev/null
+++ b/templates/go/Makefile
@@ -0,0 +1,19 @@
+.PHONY: build run clean
+
+BUILD_DIR=bin
+PROGRAM_FILE=fixproject
+VERSION=$(shell git describe --tag --always)
+BUILD_DATE ?= $(shell TZ=UTC0 git show -s --format=%cd --date=format-local:'%Y-%m-%dT%H:%M:%SZ' HEAD)
+
+build:
+ @go build \
+ -o ${BUILD_DIR}/${PROGRAM_FILE} \
+ -ldflags "-X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE}" \
+ -trimpath main.go
+
+run: build
+ @./${BUILD_DIR}/${PROGRAM_FILE}
+
+clean:
+ @go clean
+ @rm -rf ${BUILD_DIR}/${PROGRAM_FILE}