From 39c25a6d1174a796e77c65a5ddafe1b07097a244 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Fri, 12 Jan 2018 14:08:55 -0600 Subject: [PATCH] Start using goreleaser. Signed-off-by: Matt Moyer --- .gitignore | 3 +-- .goreleaser.yaml | 32 ++++++++++++++++++++++++++++++++ .travis.yml | 10 ++++++---- Makefile | 25 ++++++++++++------------- 4 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.gitignore b/.gitignore index cd10e4247..9b1c8b133 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -/heptio-authenticator-aws -/heptio-authenticator-aws-osx +/dist diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..f8ff2ba89 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,32 @@ +# Configuration for https://goreleaser.com/ +project_name: authenticator + +builds: + - binary: heptio-authenticator-aws + main: ./cmd/heptio-authenticator-aws/root.go + goos: + - darwin + - linux + goarch: + - amd64 + env: + - CGO_ENABLED=0 + +dockers: + - image: gcr.io/heptio-images/authenticator + extra_files: + - ca-certificates.crt + +snapshot: + name_template: "git-{{.Commit}}" + +archive: + format: binary + +release: + github: + owner: heptio + name: authenticator + draft: true + prerelease: true + name_template: "v{{.Version}}" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index e836b7fd6..992dd54a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,13 @@ go_import_path: github.com/heptio/authenticator go: - 1.9.x -sudo: false +sudo: required + +services: + - docker install: - - go get -u github.com/golang/dep/cmd/dep - && dep ensure -vendor-only -v + - go get github.com/goreleaser/goreleaser script: - - go install -v ./... && go test ./... + - make build test diff --git a/Makefile b/Makefile index 17dd3c6cd..f02e4fc2e 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,21 @@ default: build -CMD_IMPORT ?= github.com/heptio/authenticator/cmd/heptio-authenticator-aws -REPO ?= gcr.io/heptio-images/authenticator -VERSION ?= v0.1.0 +GORELEASER := $(shell command -v goreleaser 2> /dev/null) -.PHONY: build push build-container +.PHONY: build test format -build: build-container heptio-authenticator-aws-osx +build: ca-certificates.crt +ifndef GORELEASER + $(error "goreleaser not found (`go get -u -v github.com/goreleaser/goreleaser` to fix)") +endif + $(GORELEASER) --skip-publish --rm-dist --snapshot -heptio-authenticator-aws-osx: - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o heptio-authenticator-aws $(CMD_IMPORT) +# pull ca-certificates.crt from Alpine +ca-certificates.crt: + docker run -v "$$PWD":/out --rm --tty -i alpine:latest /bin/sh -c "apk add --update ca-certificates && cp /etc/ssl/certs/ca-certificates.crt /out/" -build-container: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o heptio-authenticator-aws $(CMD_IMPORT) - docker build . -t $(REPO):$(VERSION) - -push: - docker push $(REPO):$(VERSION) +test: + go test -v ./... format: test -z "$$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -d {} + | tee /dev/stderr)" || \