From 41ff4b4a16e39c6b3d9705bce3208747d60cc60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnblad?= Date: Fri, 17 Jul 2020 11:41:45 +0200 Subject: [PATCH] Added make commands to create artifacts and upload them to a github release --- Makefile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Makefile b/Makefile index d3fb0fbe..23e8b311 100644 --- a/Makefile +++ b/Makefile @@ -30,3 +30,31 @@ cover: go test -race -coverprofile=coverage.txt go tool cover -html=coverage.txt rm coverage.txt + +ARTIFACT_DIR := _artifacts + +# To upload artifacts for the current version; +# execute: make upload +# +# Check https://github.com/tcnksm/ghr for usage of ghr +upload: artifacts + ghr -replace $(VERS) $(ARTIFACT_DIR) + +# To build artifacts for the current version; +# execute: make artifacts +artifacts: + rm -rf $(ARTIFACT_DIR) + mkdir $(ARTIFACT_DIR) + + $(call _build,darwin,amd64) + $(call _build,linux,amd64) + $(call _build,linux,arm64) + +define _build + mkdir $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2 + env GOOS=$1 GOARCH=$2 go build -o $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2/godog ./cmd/godog + cp README.md $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2/README.md + cp LICENSE $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2/LICENSE + cd $(ARTIFACT_DIR) && tar -c --use-compress-program="pigz --fast" -f godog-$(VERS)-$1-$2.tar.gz godog-$(VERS)-$1-$2 && cd .. + rm -rf $(ARTIFACT_DIR)/godog-$(VERS)-$1-$2 +endef