diff options
author | fusion809 | 2016-07-12 14:54:23 +1000 |
---|---|---|
committer | fusion809 | 2016-07-12 14:54:23 +1000 |
commit | ffc0b71ebd2f768214f4ca7c1a0fa50c6b16ed8f (patch) | |
tree | 595061be86869df04e0567d65d957b40a85d0b43 /Makefile | |
download | aur-ffc0b71ebd2f768214f4ca7c1a0fa50c6b16ed8f.tar.gz |
Initial commit]
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..ea543b347c63 --- /dev/null +++ b/Makefile @@ -0,0 +1,81 @@ +LAST_TAG := $(shell git describe --abbrev=0 --tags) + +USER := itchio +EXECUTABLE := gothub + +# only include the amd64 binaries, otherwise the github release will become +# too big +UNIX_EXECUTABLES := \ + darwin/amd64/$(EXECUTABLE) \ + freebsd/amd64/$(EXECUTABLE) \ + linux/amd64/$(EXECUTABLE) +WIN_EXECUTABLES := \ + windows/amd64/$(EXECUTABLE).exe + +COMPRESSED_EXECUTABLES=$(UNIX_EXECUTABLES:%=%.tar.bz2) $(WIN_EXECUTABLES:%.exe=%.zip) +COMPRESSED_EXECUTABLE_TARGETS=$(COMPRESSED_EXECUTABLES:%=bin/%) + +UPLOAD_CMD = bin/tmp/$(EXECUTABLE) upload -u $(USER) -r $(EXECUTABLE) -t $(LAST_TAG) -n $(subst /,-,$(FILE)) -f bin/$(FILE) + +all: $(EXECUTABLE) + +# the executable used to perform the upload, dogfooding and all... +bin/tmp/$(EXECUTABLE): + go build -o "$@" + +# arm +bin/linux/arm/5/$(EXECUTABLE): + GOARM=5 GOARCH=arm GOOS=linux go build -o "$@" +bin/linux/arm/7/$(EXECUTABLE): + GOARM=7 GOARCH=arm GOOS=linux go build -o "$@" + +# 386 +bin/darwin/386/$(EXECUTABLE): + GOARCH=386 GOOS=darwin go build -o "$@" +bin/linux/386/$(EXECUTABLE): + GOARCH=386 GOOS=linux go build -o "$@" +bin/windows/386/$(EXECUTABLE): + GOARCH=386 GOOS=windows go build -o "$@" + +# amd64 +bin/freebsd/amd64/$(EXECUTABLE): + GOARCH=amd64 GOOS=freebsd go build -o "$@" +bin/darwin/amd64/$(EXECUTABLE): + GOARCH=amd64 GOOS=darwin go build -o "$@" +bin/linux/amd64/$(EXECUTABLE): + GOARCH=amd64 GOOS=linux go build -o "$@" +bin/windows/amd64/$(EXECUTABLE).exe: + GOARCH=amd64 GOOS=windows go build -o "$@" + +# compressed artifacts, makes a huge difference (Go executable is ~9MB, +# after compressing ~2MB) +%.tar.bz2: % + tar -jcvf "$<.tar.bz2" "$<" +%.zip: %.exe + zip "$@" "$<" + +# git tag -a v$(RELEASE) -m 'release $(RELEASE)' +release: bin/tmp/$(EXECUTABLE) $(COMPRESSED_EXECUTABLE_TARGETS) + git push && git push --tags + bin/tmp/$(EXECUTABLE) release -u $(USER) -r $(EXECUTABLE) \ + -t $(LAST_TAG) -n $(LAST_TAG) || true + $(foreach FILE,$(COMPRESSED_EXECUTABLES),$(UPLOAD_CMD);) + +# install and/or update all dependencies, run this from the project directory +# go get -u ./... +# go test -i ./ +dep: + go list -f '{{join .Deps "\n"}}' | xargs go list -e -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs go get -u + +$(EXECUTABLE): dep + go build -o "$@" + +install: + go install + +clean: + rm go-app || true + rm $(EXECUTABLE) || true + rm -rf bin/ + +.PHONY: clean release dep install |