From 7033e8db626be3b65579690e98fb3d6e6816337e Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Fri, 21 Jun 2019 17:52:00 -0700 Subject: [PATCH] added build step to makefile (#42) --- Makefile | 72 ++++++++++++++++++++++++++++++++---------- pkg/version/version.go | 2 +- 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index e74659df..3c93a616 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,59 @@ -################################################## -# Variables # -################################################## -ARCH?=amd64 -CGO?=0 -TARGET_OS?=linux - -################################################## -# Variables # -################################################## - -GIT_VERSION = $(shell git describe --always --abbrev=7) +################################################################################ +# Variables # +################################################################################ + GIT_COMMIT = $(shell git rev-list -1 HEAD) -DATE = $(shell date -u +"%Y.%m.%d.%H.%M.%S") +GIT_VERSION = $(shell git describe --always --abbrev=7 --dirty) +TARGETS ?= darwin linux windows +ARCH ?= amd64 +CGO ?= 0 +BINARIES ?= action assigner controller + +ifdef REL_VERSION + ACTIONS_VERSION := $(REL_VERSION) +else + ACTIONS_VERSION := edge +endif + +################################################################################ +# Go build details # +################################################################################ + +BASE_PACKAGE_NAME := github.com/actionscore/actions + +################################################################################ +# Dependencies # +################################################################################ + +.PHONY: dep +dep: +ifeq ($(shell command -v dep 2> /dev/null),) + go get -u -v github.com/golang/dep/cmd/dep +endif + +.PHONY: deps +deps: dep + dep ensure -v + +################################################################################ +# Build # +################################################################################ + +.PHONY: build +build: + set -e; \ + for b in $(BINARIES); do \ + for t in $(TARGETS); do \ + CGO_ENABLED=$(CGO) GOOS=$$t GOARCH=$(ARCH) go build \ + -ldflags "-X $(BASE_PACKAGE_NAME)/pkg/version.commit=$(GIT_VERSION) -X $(BASE_PACKAGE_NAME)/pkg/version.version=$(ACTIONS_VERSION)" \ + -o dist/"$$t"_$(ARCH)/$$b \ + cmd/$$b/main.go; \ + done; \ + done; -################################################## -# Tests # -################################################## +################################################################################ +# Tests # +################################################################################ .PHONY: test test: - go test ./pkg/... \ No newline at end of file + go test ./pkg/... diff --git a/pkg/version/version.go b/pkg/version/version.go index 37d78a01..b205dc56 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -7,7 +7,7 @@ var ( ) // Version returns the Actions version. This is either a semantic version -// number or else, in the case of unreleased code, the string "devel". +// number or else, in the case of unreleased code, the string "edge". func Version() string { return version } -- GitLab