This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
forked from webdevops/go-crond
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
86 lines (66 loc) · 3.57 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
SOURCE = $(wildcard *.go)
TAG ?= $(shell git describe --tags)
GOBUILD_OSX = go build --ldflags '-w'
GOBUILD_DYNAMIC = go build --ldflags '\''-w'\''
GOBUILD_STATIC = go build --ldflags '\''-linkmode external -extldflags "-static" -w'\''
.PHONY: docker docker-dev docker-run-dev all build test clean release dependencies
ALL = \
$(foreach arch,64 32,\
$(foreach suffix,linux osx,\
build/go-crond-$(arch)-$(suffix))) \
$(foreach arch,arm arm64,\
build/go-crond-$(arch)-linux)
docker:
docker build . -t webdevops/go-crond
docker-dev:
docker build -f Dockerfile.develop . -t webdevops/go-crond:develop
docker-run: docker-dev
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd):ro" --name=cron webdevops/go-crond:develop bash
build-env: docker-dev
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop bash
all: test build
dependencies:
go get -u github.com/robfig/cron
go get -u github.com/jessevdk/go-flags
build: clean dependencies test $(ALL)
# cram is a python app, so 'easy_install/pip install cram' to run tests
test:
echo test todo
#cram tests/main.test
clean:
rm -rf build/
# os is determined as thus: if variable of suffix exists, it's taken, if not, then
# suffix itself is taken
osx = darwin
build/go-crond-64-osx: $(SOURCE)
@mkdir -p $(@D)
CGO_ENABLED=1 GOOS=$(firstword $($*) $*) GOARCH=amd64 $(GOBUILD_OSX) -o $@
build/go-crond-32-osx: $(SOURCE)
@mkdir -p $(@D)
CGO_ENABLED=1 GOOS=$(firstword $($*) $*) GOARCH=386 $(GOBUILD_OSX) -o $@
build/go-crond-64-linux: $(SOURCE)
@mkdir -p $(@D)
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CGO_ENABLED=1 GOOS=$(firstword $($*) $*) GOARCH=amd64 $(GOBUILD_DYNAMIC) -o ${@}-dynamic'
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CGO_ENABLED=1 GOOS=$(firstword $($*) $*) GOARCH=amd64 $(GOBUILD_STATIC) -o ${@}'
build/go-crond-32-linux: $(SOURCE)
@mkdir -p $(@D)
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CGO_ENABLED=1 GOOS=$(firstword $($*) $*) GOARCH=386 $(GOBUILD_DYNAMIC) -o ${@}-dynamic'
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CGO_ENABLED=1 GOOS=$(firstword $($*) $*) GOARCH=386 $(GOBUILD_STATIC) -o ${@}'
build/go-crond-arm-linux: $(SOURCE)
@mkdir -p $(@D)
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD_DYNAMIC) -o ${@}-dynamic'
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD_STATIC) -o ${@}'
build/go-crond-arm64-linux: $(SOURCE)
@mkdir -p $(@D)
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 $(GOBUILD_STATIC) -o ${@}'
docker run -ti --rm -w "$$(pwd)" -v "$$(pwd):$$(pwd)" --name=cron webdevops/go-crond:develop sh -c 'CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 $(GOBUILD_DYNAMIC) -o ${@}-dynamic'
release:
github-release release -u webdevops -r go-crond -t "$(TAG)" -n "$(TAG)" --description "$(TAG)"
@for x in build/*; do \
echo "Uploading $$x" && \
github-release upload -u webdevops \
-r go-crond \
-t $(TAG) \
-f "$$x" \
-n "$$(basename $$x)"; \
done