2019-04-18 14:59:55 +00:00
|
|
|
# UID/GID
|
|
|
|
# UID or GID is the UNIX user ID or group ID of the user who executes
|
|
|
|
# make. If the UID or GID is not passed as a make variable, an attempt
|
|
|
|
# is made to determine it.
|
2019-05-12 09:57:53 +00:00
|
|
|
UID?=$(shell id --user)
|
|
|
|
GID?=$(shell id --group)
|
2019-04-18 14:59:55 +00:00
|
|
|
|
|
|
|
# VERSION
|
|
|
|
# If no version is specified as a parameter of make, the last git hash
|
|
|
|
# value is taken.
|
2019-08-20 19:37:45 +00:00
|
|
|
VERSION:=$(or ${TRAVIS_TAG}, $(shell git rev-parse --short HEAD)-git)
|
2018-11-07 19:07:15 +00:00
|
|
|
|
2019-08-25 14:31:52 +00:00
|
|
|
# CONTAINER_RUNTIME
|
2019-06-16 21:39:07 +00:00
|
|
|
CONTAINER_RUNTIME?=$(shell which docker)
|
|
|
|
|
2019-08-25 14:31:52 +00:00
|
|
|
# BUILD_IMAGE
|
|
|
|
BUILD_IMAGE:=volkerraschek/build-image:latest
|
|
|
|
|
|
|
|
# GO ENVIRONMENT
|
2019-04-18 15:10:03 +00:00
|
|
|
GOARCH?=amd64
|
|
|
|
GOOS?=linux
|
2019-04-18 14:59:55 +00:00
|
|
|
|
|
|
|
# default build
|
2019-08-20 19:37:45 +00:00
|
|
|
go-build: bindata
|
2019-04-18 15:10:03 +00:00
|
|
|
GOOS=${GOOS} \
|
|
|
|
GOARCH=${GOARCH} \
|
|
|
|
go build -ldflags "-X main.version=${VERSION}"
|
2019-08-25 14:31:52 +00:00
|
|
|
chown ${UID}:${GID} ./*
|
2018-11-07 19:07:15 +00:00
|
|
|
|
2019-08-20 19:37:45 +00:00
|
|
|
go-test: go-build
|
2019-06-14 19:35:13 +00:00
|
|
|
go test -v ./pkg/...
|
|
|
|
|
2019-08-25 14:31:52 +00:00
|
|
|
rpm-build: go-build
|
|
|
|
rpm-builder \
|
|
|
|
--arch x86_64 \
|
|
|
|
--compression gzip \
|
|
|
|
--exec-file "flucky:/usr/bin/flucky" \
|
|
|
|
--file "systemd/flucky.service:/usr/lib/systemd/system/flucky.service" \
|
|
|
|
--version ${VERSION} \
|
|
|
|
flucky-${VERSION}
|
|
|
|
|
2019-06-14 19:35:13 +00:00
|
|
|
bindata:
|
2019-08-20 19:37:45 +00:00
|
|
|
go-bindata -pkg db -o ./pkg/db/bindataSQL.go ./pkg/db/sql/***
|
|
|
|
go-bindata -pkg goldenfiles -o ./test/goldenfiles/bindata.go ./test/goldenfiles/json/***
|
2019-06-14 19:35:13 +00:00
|
|
|
|
2019-08-20 19:37:45 +00:00
|
|
|
container-go-build:
|
|
|
|
$(MAKE) container-run COMMAND=go-build
|
2019-06-15 17:12:27 +00:00
|
|
|
|
2019-08-20 19:37:45 +00:00
|
|
|
container-go-test:
|
|
|
|
$(MAKE) container-run COMMAND=go-test
|
2019-06-15 17:12:27 +00:00
|
|
|
|
2019-08-25 14:31:52 +00:00
|
|
|
container-rpm-build:
|
|
|
|
$(MAKE) container-run COMMAND=rpm-build
|
|
|
|
|
2019-06-15 17:12:27 +00:00
|
|
|
container-run:
|
2019-06-16 21:39:07 +00:00
|
|
|
${CONTAINER_RUNTIME} run \
|
|
|
|
--rm \
|
2019-08-25 14:31:52 +00:00
|
|
|
--volume ${PWD}:/workspace \
|
|
|
|
${BUILD_IMAGE} \
|
|
|
|
make ${COMMAND} \
|
|
|
|
UID=${UID} \
|
|
|
|
GID=${GID} \
|
|
|
|
VERSION=${VERSION} \
|
|
|
|
GOOS=${GOOS} \
|
|
|
|
GOARCH=${GOARCH}
|
2019-06-11 18:07:55 +00:00
|
|
|
|
2019-06-15 09:46:37 +00:00
|
|
|
remote:
|
2019-08-20 19:37:45 +00:00
|
|
|
$(MAKE) go-build GOARCH=arm
|
2019-06-15 09:46:37 +00:00
|
|
|
scp flucky ${FLUCKY_REMOTE}:/usr/local/bin
|
2019-06-18 21:02:11 +00:00
|
|
|
ssh ${FLUCKY_REMOTE} "chmod +x /usr/local/bin/flucky"
|