Skip to content

Commit

Permalink
build: build next release with goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Dec 20, 2017
1 parent c341f74 commit 5aa9e12
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ fabio
fabio.sublime-*
demo/cert/
pkg/
dist/
34 changes: 34 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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 }}'

18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"
Expand All @@ -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`

Expand Down
27 changes: 27 additions & 0 deletions build/tag.sh
Original file line number Diff line number Diff line change
@@ -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 <version> (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}"

0 comments on commit 5aa9e12

Please sign in to comment.