diff --git a/.gitignore b/.gitignore index ce1bc6a39..f1652b958 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ fabio fabio.sublime-* demo/cert/ pkg/ +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..41b14437f --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,34 @@ +builds: + - + binary: release-test + env: + - CGO_ENABLED=0 + goos: + - darwin + - linux + - freebsd + - netbsd + - openbsd + goarch: + - 386 + - amd64 + - arm + +archive: + name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Env.GOVERSION }}-{{ .Os }}_{{ .Arch }}' + format: binary + +checksum: + name_template: '{{.ProjectName}}-{{ .Env.GOVERSION }}-{{.Version}}.sha256' + +sign: + artifacts: checksum + +dockers: + - image: fabiolb/fabio + latest: true + tag_template: '{{ .Version }}-{{ .Env.GOVERSION }}' + - image: magiconair/fabio + latest: true + tag_template: '{{ .Version }}-{{ .Env.GOVERSION }}' + diff --git a/Makefile b/Makefile index 58496d64c..e28da5df5 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,14 @@ +CUR_TAG = $(shell git describe) +LAST_TAG = $(shell git describe --abbrev=0) + # do not specify a full path for go since travis will fail GO = GOGC=off go -GOFLAGS = -ldflags "-X main.version=$(shell git describe --tags)" +GOFLAGS = -ldflags "-X main.version=$(CUR_TAG)" +GORELEASER = $(shell which goreleaser) GOVENDOR = $(shell which govendor) VENDORFMT = $(shell which vendorfmt) +GOVERSION = $(shell go version | awk '{print $$3;}') all: build test @@ -15,6 +20,7 @@ help: @echo "vet - go vet" @echo "linux - go build linux/amd64" @echo "release - build/release.sh" + @echo "gorelease - goreleaser" @echo "homebrew - build/homebrew.sh" @echo "buildpkg - build/build.sh" @echo "pkg - build, test and create pkg/fabio.tar.gz" @@ -35,6 +41,16 @@ vendorfmt: [ -x "$(VENDORFMT)" ] || $(GO) get -u github.com/magiconair/vendorfmt/cmd/vendorfmt vendorfmt +tag: + build/tag.sh + +gorelease: + [ -x "$(GORELEASER)" ] || ( echo "goreleaser not installed"; exit 1) + [ "$(CUR_TAG)" == "$(LAST_TAG)" ] || ( echo "master not tagged. Last tag is $(LAST_TAG)" ; exit 1 ) + grep -q "$(LAST_TAG)" CHANGELOG.md main.go || ( echo "CHANGELOG.md or main.go not updated. $(LAST_TAG) not found"; exit 1 ) + GOVERSION=$(GOVERSION) goreleaser --rm-dist + build/homebrew.sh $(LAST_TAG) + gofmt: gofmt -s -w `find . -type f -name '*.go' | grep -v vendor` diff --git a/build/tag.sh b/build/tag.sh new file mode 100755 index 000000000..c6f225263 --- /dev/null +++ b/build/tag.sh @@ -0,0 +1,27 @@ +#!/bin/bash -e +# +# Script for replacing the version number +# in main.go, committing and tagging the code + +readonly prgdir=$(cd $(dirname $0); pwd) +readonly basedir=$(cd $prgdir/..; pwd) +v=$1 + +[[ -n "$v" ]] || read -p "Enter version (e.g. 1.0.4): " v +if [[ -z "$v" ]]; then + echo "Usage: $0 (e.g. 1.0.4)" + exit 1 +fi + +grep -q "$v" CHANGELOG.md || echo "CHANGELOG.md not updated" + +read -p "Tag fabio version $v? (y/N) " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 +fi + +sed -i '' -e "s|^var version .*$|var version = \"$v\"|" $basedir/main.go +git add $basedir/main.go +git commit -S -m "Release v$v" +git tag -s v$v -m "Tag v${v}"