Skip to content

Commit

Permalink
Update build to use GOOS rather than docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mtibben committed Sep 26, 2018
1 parent f2b80d1 commit 60f046e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# the current tag else the current git sha
VERSION := $(shell git tag --points-at=HEAD | grep . || git rev-parse --short HEAD)

GOBUILD_ARGS := -ldflags "-X main.Version=$(VERSION)"
OS := $(shell go env GOOS)
ARCH := $(shell go env GOHOSTARCH)
VERSION=$(shell git describe --tags --candidates=1 --dirty)
FLAGS=-X main.Version=$(VERSION) -s -w

# To create a new release:
# $ git tag vx.x.x
# $ git push --tags
# $ make clean
# $ make release # this will create 2 binaries in ./bin - darwin and linux
# $ make release # this will create 3 binaries in ./bin
#
# Next, go to https://github.com/99designs/iamy/releases/new
# - select the tag version you just created
# - Attach the binaries from ./bin/*

release: bin/iamy-linux-amd64 bin/iamy-$(OS)-$(ARCH)
release: bin/iamy-linux-amd64 bin/iamy-darwin-amd64 bin/iamy-windows-386.exe

bin/iamy-linux-amd64:
@mkdir -p bin
docker run -it -v $$GOPATH:/go golang:latest go build $(GOBUILD_ARGS) -o /go/src/github.com/99designs/iamy/$@ github.com/99designs/iamy
GOOS=linux GOARCH=amd64 go build -o $@ -ldflags="$(FLAGS)" .

bin/iamy-darwin-amd64:
@mkdir -p bin
GOOS=darwin GOARCH=amd64 go build -o $@ -ldflags="$(FLAGS)" .

bin/iamy-$(OS)-$(ARCH):
bin/iamy-windows-386.exe:
@mkdir -p bin
go build $(GOBUILD_ARGS) -o bin/iamy-$(OS)-$(ARCH) .
GOOS=windows GOARCH=386 go build -o $@ -ldflags="$(FLAGS)" .

clean:
rm -f bin/*

0 comments on commit 60f046e

Please sign in to comment.