11# the filepath to this repository, relative to $GOPATH/src
2- repo_path = github.com/drycc/workflow-cli
2+ REPO_PATH := github.com/drycc/workflow-cli
3+ DEV_ENV_IMAGE := quay.io/drycc/go-dev:v0.22.0
4+ DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
35
46HOST_OS := $(shell uname)
57ifeq ($(HOST_OS ) ,Darwin)
@@ -21,54 +23,28 @@ BUILD_ARCH ?=amd64 386
2123
2224DIST_DIR ?= _dist
2325
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
26+ DEV_ENV_CMD := docker run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
3227
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/drycc .
36- @$(call check-static-binary,_dist/drycc)
37- @echo " ${GOOS} binary written to _dist/drycc"
28+ define build-install-script
29+ sed "s|{{DRYCC-CLIENT-VERSION}}|${GIT_TAG}|g" "install.tmpl" > "${DIST_DIR}/$(1 ) /install-drycc.sh"
30+ endef
3831
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} /drycc-latest-{{.OS}}-{{.Arch}}" .
32+ bootstrap :
33+ ${DEV_ENV_CMD} dep ensure
4334
4435# This is supposed to be run within a docker container
4536build-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} /drycc-${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} /drycc-stable-{{.OS}}-{{.Arch}}" .
37+ ${DEV_ENV_CMD} gox -verbose ${GO_LDFLAGS} -os=" ${BUILD_OS} " -arch=" ${BUILD_ARCH} " -output=" ${DIST_DIR} /${REVISION} /drycc-${REVISION} -{{.OS}}-{{.Arch}}" .
5338
5439# This is supposed to be run within a docker container
5540build-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} /drycc-${GIT_TAG} -{{.OS}}-{{.Arch}}" .
58-
59- build-all : build-latest build-revision
41+ ${DEV_ENV_CMD} gox -verbose ${GO_LDFLAGS} -os=" ${BUILD_OS} " -arch=" ${BUILD_ARCH} " -output=" ${DIST_DIR} /${GIT_TAG} /drycc-${GIT_TAG} -{{.OS}}-{{.Arch}}" .
42+ @$(call build-install-script,${GIT_TAG})
6043
61- install :
62- cp drycc $$ GOPATH/bin
44+ build : build-tag build-revision
6345
6446test-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} .
47+ ${DEV_ENV_CMD} lint
7248
73- push- test-image : build-test-image
74- docker push ${IMAGE}
49+ test :
50+ ${DEV_ENV_CMD} test
0 commit comments