github.com/engineyard/workflow-cli@v2.21.6+incompatible/Makefile (about) 1 # the filepath to this repository, relative to $GOPATH/src 2 repo_path = github.com/teamhephy/workflow-cli 3 4 HOST_OS := $(shell uname) 5 ifeq ($(HOST_OS),Darwin) 6 GOOS=darwin 7 else 8 GOOS=linux 9 endif 10 11 # The latest git tag on branch 12 GIT_TAG ?= $(shell git describe --abbrev=0 --tags) 13 REVISION ?= $(shell git rev-parse --short HEAD) 14 15 REGISTRY ?= quay.io/ 16 IMAGE_PREFIX ?= deisci 17 IMAGE := ${REGISTRY}${IMAGE_PREFIX}/workflow-cli-dev:${REVISION} 18 19 BUILD_OS ?=linux darwin windows 20 BUILD_ARCH ?=amd64 386 21 22 DIST_DIR ?= _dist 23 24 define check-static-binary 25 if file $(1) | egrep -q "(statically linked|Mach-O)"; then \ 26 echo -n ""; \ 27 else \ 28 echo "The binary file $(1) is not statically linked. Build canceled"; \ 29 exit 1; \ 30 fi 31 endef 32 33 build: build-test-image 34 $(eval GO_LDFLAGS= -ldflags '-X ${repo_path}/version.Version=dev-${REVISION}') 35 docker run --rm -e GOOS=${GOOS} -v ${CURDIR}/_dist:/out ${IMAGE} go build -a -installsuffix cgo ${GO_LDFLAGS} -o /out/deis . 36 @$(call check-static-binary,_dist/deis) 37 @echo "${GOOS} binary written to _dist/deis" 38 39 # This is supposed to be run within a docker container 40 build-latest: 41 $(eval GO_LDFLAGS = -ldflags '-X ${repo_path}/version.Version=${GIT_TAG}-${REVISION}') 42 gox -verbose ${GO_LDFLAGS} -os="${BUILD_OS}" -arch="${BUILD_ARCH}" -output="${DIST_DIR}/deis-latest-{{.OS}}-{{.Arch}}" . 43 44 # This is supposed to be run within a docker container 45 build-revision: 46 $(eval GO_LDFLAGS = -ldflags '-X ${repo_path}/version.Version=${GIT_TAG}-${REVISION}') 47 gox -verbose ${GO_LDFLAGS} -os="${BUILD_OS}" -arch="${BUILD_ARCH}" -output="${DIST_DIR}/${REVISION}/deis-${REVISION}-{{.OS}}-{{.Arch}}" . 48 49 # This is supposed to be run within a docker container 50 build-stable: 51 $(eval GO_LDFLAGS = -ldflags '-X ${repo_path}/version.Version=${GIT_TAG}') 52 gox -verbose ${GO_LDFLAGS} -os="${BUILD_OS}" -arch="${BUILD_ARCH}" -output="${DIST_DIR}/deis-stable-{{.OS}}-{{.Arch}}" . 53 54 # This is supposed to be run within a docker container 55 build-tag: 56 $(eval GO_LDFLAGS = -ldflags '-X ${repo_path}/version.Version=${GIT_TAG}') 57 gox -verbose ${GO_LDFLAGS} -os="${BUILD_OS}" -arch="${BUILD_ARCH}" -output="${DIST_DIR}/${GIT_TAG}/deis-${GIT_TAG}-{{.OS}}-{{.Arch}}" . 58 59 build-all: build-latest build-revision 60 61 install: 62 cp deis $$GOPATH/bin 63 64 test-style: build-test-image 65 docker run --rm ${IMAGE} lint 66 67 test: build-test-image 68 docker run --rm ${IMAGE} test 69 70 build-test-image: 71 docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} . 72 73 push-test-image: build-test-image 74 docker push ${IMAGE}