diff --git a/.drone.yml b/.drone.yml index 340a30b..6af0615 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,3 +19,24 @@ steps: - mkdir -p /go/bin - go mod download - make test + - name: build + image: golang:1.13 + commands: + - ./hack/build.sh + environment: + BUILD_ARCHS: "linux/amd64 linux/arm64 linux/arm darwin/amd64 windows/amd64" + when: + event: tag + - name: publish + image: plugins/github-release + settings: + api_key: + from_secret: github_token + files: + - output/* + draft: true + checksum: + - md5 + - sha256 + when: + event: tag diff --git a/hack/build.sh b/hack/build.sh new file mode 100755 index 0000000..6ef27e7 --- /dev/null +++ b/hack/build.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -eox + +# To easily cross-compile binaries +GO111MODULE=off go get github.com/mitchellh/gox + +VERSION=${DRONE_TAG:-latest} +GIT_COMMIT=$(git rev-list -1 HEAD || echo 'dirrrty') + +CURRENT_ARCH="$(go env GOOS)/$(go env GOARCH)" + +BUILD_ARCHS=${BUILD_ARCHS:-$CURRENT_ARCH} + +mkdir -p output +CGO_ENABLED=0 gox -output="output/trieres_{{.OS}}_{{.Arch}}" \ + -osarch="${BUILD_ARCHS}" \ + -ldflags "-s -w -X github.com/jakolehm/trieres/main.Version=${VERSION}" \ + github.com/jakolehm/trieres/