-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add make dist command to build version binary releases
- Loading branch information
Andras Ferencz-Szabo
committed
Nov 29, 2019
1 parent
6ad1d92
commit d175812
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,49 @@ | ||
.PHONY: all clean test build | ||
|
||
DOCKER_REPOSITORY ?= monzo | ||
DOCKER_TAG ?= latest | ||
DOCKER_IMAGE ?= $(DOCKER_REPOSITORY)/kontrast:$(DOCKER_TAG) | ||
|
||
ALL_GOARCH = amd64 | ||
ALL_GOOS = linux darwin | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f bin/ | ||
rm -rf bin/ | ||
|
||
.PHONY: build | ||
build: | ||
mkdir -p bin/ | ||
dep ensure -v | ||
go build -o bin/kontrast ./cmd/kontrast | ||
|
||
.PHONY: kontrastd | ||
kontrastd: | ||
mkdir -p bin/ | ||
dep ensure -v | ||
go build -o bin/kontrastd ./cmd/kontrastd | ||
|
||
.PHONY: build-in-docker | ||
build-in-docker: | ||
dep ensure -vendor-only -v | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/kontrastd ./cmd/kontrastd | ||
|
||
.PHONY: build-linux | ||
build-linux: | ||
mkdir -p bin/ | ||
dep ensure -v | ||
GOOS=linux go build -o bin/kontrast ./cmd/kontrast | ||
|
||
.PHONY: dist | ||
dist: | ||
$(eval export ALL_GOARCH) | ||
$(eval export ALL_GOOS) | ||
mkdir -p bin/ | ||
NAME=kontrast ./dist.sh | ||
|
||
.PHONY: docker | ||
docker: | ||
docker build . -t $(DOCKER_IMAGE) | ||
|
||
.PHONY: docker-push | ||
docker-push: docker | ||
docker push $(DOCKER_IMAGE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
VERSION="" | ||
if [ -z "${VERSION}" ]; then | ||
VERSION=$(git tag | sort -r --version-sort | head -n1) | ||
fi | ||
|
||
if [ -z "${VERSION}" ]; then | ||
echo "VERSION can not be empty" | ||
fi | ||
|
||
VERSION=${VERSION/v/} | ||
|
||
echo "Building version ${VERSION}" | ||
|
||
mkdir -p bin | ||
|
||
for arch in ${ALL_GOARCH}; do | ||
for platform in ${ALL_GOOS}; do | ||
file="bin/${NAME}-${VERSION}.${platform}.${arch}" | ||
echo "Building ${file}" | ||
CGO_ENABLED=0 GOOS=${platform} GOARCH=${arch} go build -ldflags="-s -w" -o ${file} ./cmd/${NAME} | ||
done | ||
done | ||
|
||
cd bin && shasum -a 256 ${NAME}-${VERSION}.* > ${NAME}-${VERSION}.sha256sums |