2019-01-04 10:58:30 +00:00
|
|
|
include .env
|
|
|
|
BINARY := oauth2_proxy
|
|
|
|
VERSION := $(shell git describe --always --long --dirty --tags 2>/dev/null || echo "undefined")
|
2019-01-07 16:41:11 +00:00
|
|
|
.NOTPARALLEL:
|
2019-01-04 10:58:30 +00:00
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: dep lint $(BINARY)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf release
|
|
|
|
rm -f $(BINARY)
|
|
|
|
|
|
|
|
.PHONY: distclean
|
|
|
|
distclean: clean
|
|
|
|
rm -rf vendor
|
|
|
|
|
|
|
|
BIN_DIR := $(GOPATH)/bin
|
|
|
|
GOMETALINTER := $(BIN_DIR)/gometalinter
|
|
|
|
|
|
|
|
$(GOMETALINTER):
|
|
|
|
$(GO) get -u github.com/alecthomas/gometalinter
|
|
|
|
gometalinter --install %> /dev/null
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint: $(GOMETALINTER)
|
|
|
|
$(GOMETALINTER) --vendor --disable-all \
|
|
|
|
--enable=vet \
|
|
|
|
--enable=vetshadow \
|
|
|
|
--enable=golint \
|
|
|
|
--enable=ineffassign \
|
|
|
|
--enable=goconst \
|
|
|
|
--enable=deadcode \
|
|
|
|
--enable=gofmt \
|
|
|
|
--enable=goimports \
|
|
|
|
--tests ./...
|
|
|
|
|
|
|
|
.PHONY: dep
|
|
|
|
dep:
|
|
|
|
$(DEP) ensure --vendor-only
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build: clean $(BINARY)
|
|
|
|
|
|
|
|
$(BINARY):
|
2019-01-21 17:49:41 +00:00
|
|
|
CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/pusher/oauth2_proxy
|
2019-01-04 10:58:30 +00:00
|
|
|
|
2019-02-01 23:08:19 +00:00
|
|
|
# Ubuntu 18.04.1 Qemu version
|
|
|
|
QEMU-STATIC-VERSION=v2.11.1
|
|
|
|
|
|
|
|
.PHONY: qemu-static
|
|
|
|
qemu-static:
|
|
|
|
wget -O dist/qemu-amd64-static https://github.com/multiarch/qemu-user-static/releases/download/${QEMU-STATIC-VERSION}/qemu-x86_64-static
|
|
|
|
wget -O dist/qemu-aarch64-static https://github.com/multiarch/qemu-user-static/releases/download/${QEMU-STATIC-VERSION}/qemu-aarch64-static
|
|
|
|
wget -O dist/qemu-arm-static https://github.com/multiarch/qemu-user-static/releases/download/${QEMU-STATIC-VERSION}/qemu-arm-static
|
|
|
|
chmod +x dist/qemu-*-static
|
|
|
|
|
|
|
|
.PHONY: qemu-register
|
|
|
|
qemu-register:
|
|
|
|
docker run --rm --privileged multiarch/qemu-user-static:register
|
|
|
|
|
|
|
|
.PHONY: docker
|
|
|
|
docker:
|
|
|
|
docker build -f Dockerfile -t pusher/oauth2_proxy:latest .
|
|
|
|
|
|
|
|
.PHONY: docker-all
|
|
|
|
docker-all: qemu-static docker
|
|
|
|
docker build -f Dockerfile -t pusher/oauth2_proxy:latest-amd64 .
|
|
|
|
docker build -f Dockerfile -t pusher/oauth2_proxy:${VERSION} .
|
|
|
|
docker build -f Dockerfile -t pusher/oauth2_proxy:${VERSION}-amd64 .
|
|
|
|
docker build -f Dockerfile.arm64 -t pusher/oauth2_proxy:latest-arm64 .
|
|
|
|
docker build -f Dockerfile.arm64 -t pusher/oauth2_proxy:${VERSION}-arm64 .
|
|
|
|
docker build -f Dockerfile.armv6 -t pusher/oauth2_proxy:latest-armv6 .
|
|
|
|
docker build -f Dockerfile.armv6 -t pusher/oauth2_proxy:${VERSION}-armv6 .
|
|
|
|
|
2019-01-04 10:58:30 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: dep lint
|
|
|
|
$(GO) test -v -race $(go list ./... | grep -v /vendor/)
|
|
|
|
|
|
|
|
.PHONY: release
|
2019-01-07 16:41:11 +00:00
|
|
|
release: lint test
|
2019-01-04 10:58:30 +00:00
|
|
|
mkdir release
|
|
|
|
GOOS=darwin GOARCH=amd64 go build -ldflags="-X main.VERSION=${VERSION}" -o release/$(BINARY)-darwin-amd64 github.com/pusher/oauth2_proxy
|
|
|
|
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.VERSION=${VERSION}" -o release/$(BINARY)-linux-amd64 github.com/pusher/oauth2_proxy
|
2019-01-31 18:52:08 +00:00
|
|
|
GOOS=linux GOARCH=arm64 go build -ldflags="-X main.VERSION=${VERSION}" -o release/$(BINARY)-linux-arm64 github.com/pusher/oauth2_proxy
|
|
|
|
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-X main.VERSION=${VERSION}" -o release/$(BINARY)-linux-armv6 github.com/pusher/oauth2_proxy
|
2019-01-14 10:39:21 +00:00
|
|
|
GOOS=windows GOARCH=amd64 go build -ldflags="-X main.VERSION=${VERSION}" -o release/$(BINARY)-windows-amd64 github.com/pusher/oauth2_proxy
|
|
|
|
shasum -a 256 release/$(BINARY)-darwin-amd64 > release/$(BINARY)-darwin-amd64-sha256sum.txt
|
|
|
|
shasum -a 256 release/$(BINARY)-linux-amd64 > release/$(BINARY)-linux-amd64-sha256sum.txt
|
2019-01-31 18:52:08 +00:00
|
|
|
shasum -a 256 release/$(BINARY)-linux-arm64 > release/$(BINARY)-linux-arm64-sha256sum.txt
|
|
|
|
shasum -a 256 release/$(BINARY)-linux-armv6 > release/$(BINARY)-linux-armv6-sha256sum.txt
|
2019-01-14 10:39:21 +00:00
|
|
|
shasum -a 256 release/$(BINARY)-windows-amd64 > release/$(BINARY)-windows-amd64-sha256sum.txt
|
|
|
|
tar -cvf release/$(BINARY)-$(VERSION).darwin-amd64.$(GO_VERSION).tar.gz release/$(BINARY)-darwin-amd64
|
|
|
|
tar -cvf release/$(BINARY)-$(VERSION).linux-amd64.$(GO_VERSION).tar.gz release/$(BINARY)-linux-amd64
|
2019-01-31 18:52:08 +00:00
|
|
|
tar -cvf release/$(BINARY)-$(VERSION).linux-arm64.$(GO_VERSION).tar.gz release/$(BINARY)-linux-arm64
|
|
|
|
tar -cvf release/$(BINARY)-$(VERSION).linux-armv6.$(GO_VERSION).tar.gz release/$(BINARY)-linux-armv6
|
2019-01-14 10:39:21 +00:00
|
|
|
tar -cvf release/$(BINARY)-$(VERSION).windows-amd64.$(GO_VERSION).tar.gz release/$(BINARY)-windows-amd64
|