Makefile: make cross-building more flexible [skip ci]

This commit is contained in:
Leo Antunes 2019-07-13 10:48:16 +02:00
parent 48cf5ff9dd
commit ddfc751b71
2 changed files with 16 additions and 8 deletions

View File

@ -42,8 +42,9 @@ jobs:
go: "1.12" go: "1.12"
script: make e2e script: make e2e
- stage: release - stage: release
script: make build script: make release GOARCHES="amd64 arm arm64"
go: "1.12.1" # explicit version to ease reproducibility go: "1.12.7" # explicit version to ease reproducibility
if: tag IS present
deploy: deploy:
provider: releases provider: releases
api_key: api_key:

View File

@ -1,12 +1,19 @@
VERSION=`git describe --tags --dirty --always` VERSION := $(shell git describe --tags --dirty --always)
GOFLAGS=-ldflags "-X main.version=${VERSION}" -gcflags=all=-trimpath=$(PWD) -asmflags=all=-trimpath=$(PWD) GOFLAGS := -ldflags "-X main.version=$(VERSION)" -gcflags=all=-trimpath=$(PWD) -asmflags=all=-trimpath=$(PWD)
GOARCHES := $(shell go env GOARCH)
build: build:
GOARCH=amd64 go build ${GOFLAGS} -o wesher-amd64 ${OPTS} $(foreach GOARCH,$(GOARCHES),GOARCH=$(GOARCH) go build ${GOFLAGS} -o wesher$(if $(filter-out $(GOARCH), $(GOARCHES)),-$(GOARCH));)
GOARCH=arm go build ${GOFLAGS} -o wesher-arm ${OPTS}
GOARCH=arm64 go build ${GOFLAGS} -o wesher-arm64 ${OPTS} release: build
sha256sum wesher-* > wesher.sha256sums sha256sum wesher-* > wesher.sha256sums
e2e: e2e:
tests/e2e.sh tests/e2e.sh
clean:
rm -f wesher wesher-* wesher.sha256sums
.PHONY: build release e2e clean