|
| 1 | +SOURCE = $(wildcard *.go) |
| 2 | +TAG ?= $(shell git describe --tags) |
| 3 | +GOBUILD = go build -ldflags '-w' |
| 4 | + |
| 5 | +ALL = \ |
| 6 | + $(foreach arch,64 32,\ |
| 7 | + $(foreach suffix,linux osx,\ |
| 8 | + build/gosync-$(arch)-$(suffix))) \ |
| 9 | + $(foreach arch,arm arm64,\ |
| 10 | + build/gosync-$(arch)-linux) |
| 11 | + |
| 12 | +all: test build |
| 13 | + |
| 14 | +build: clean test $(ALL) |
| 15 | + |
| 16 | +# cram is a python app, so 'easy_install/pip install cram' to run tests |
| 17 | +test: |
| 18 | + echo "No tests" |
| 19 | + #cram tests/*.test |
| 20 | + |
| 21 | +clean: |
| 22 | + rm -f $(ALL) |
| 23 | + |
| 24 | +# os is determined as thus: if variable of suffix exists, it's taken, if not, then |
| 25 | +# suffix itself is taken |
| 26 | +osx = darwin |
| 27 | +build/gosync-64-%: $(SOURCE) |
| 28 | + @mkdir -p $(@D) |
| 29 | + CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=amd64 $(GOBUILD) -o $@ |
| 30 | + |
| 31 | +build/gosync-32-%: $(SOURCE) |
| 32 | + @mkdir -p $(@D) |
| 33 | + CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=386 $(GOBUILD) -o $@ |
| 34 | + |
| 35 | +build/gosync-arm-linux: $(SOURCE) |
| 36 | + @mkdir -p $(@D) |
| 37 | + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD) -o $@ |
| 38 | + |
| 39 | +build/gosync-arm64-linux: $(SOURCE) |
| 40 | + @mkdir -p $(@D) |
| 41 | + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GOBUILD) -o $@ |
| 42 | + |
| 43 | +release: build |
| 44 | + github-release release -u webdevops -r go-sync -t "$(TAG)" -n "$(TAG)" --description "$(TAG)" |
| 45 | + @for x in $(ALL); do \ |
| 46 | + echo "Uploading $$x" && \ |
| 47 | + github-release upload -u webdevops \ |
| 48 | + -r go-sync \ |
| 49 | + -t $(TAG) \ |
| 50 | + -f "$$x" \ |
| 51 | + -n "$$(basename $$x)"; \ |
| 52 | + done |
0 commit comments