diff --git a/Makefile b/Makefile index e74659df2b18d990347b80c6900a9fcebdd41e07..3c93a61666ea2b55488724f0937b82ad63d6b8aa 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 37d78a019bce124046e5d251a1b23f63c227c276..b205dc56de7ba70320043da2e5e58438a33b153d 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 }