diff options
author | Vincent Ambo <tazjin@gmail.com> | 2017-05-08T09·12+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2017-05-08T09·15+0200 |
commit | 1e3ecad709691256d5dabcab448e946aa543bb85 (patch) | |
tree | f43d4841991b9ed12cfc71dc9531ac9ae642e9d2 /build-release.sh | |
parent | d93bc51e86081c7331554167fbba1318ac9a4927 (diff) |
feat release: Add simple release script
Adds a simple script that will build stripped binaries for various platforms and GPG-sign them.
Diffstat (limited to 'build-release.sh')
-rwxr-xr-x | build-release.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/build-release.sh b/build-release.sh new file mode 100755 index 000000000000..d70bd3eea25a --- /dev/null +++ b/build-release.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -ueo pipefail + +readonly GIT_HASH="$(git rev-parse --short HEAD)" +readonly LDFLAGS="-X main.gitHash=${GIT_HASH} -w -s" +readonly VERSION="1.0-${GIT_HASH}" + +function build-for() { + local os="${1}" + local arch="${2}" + local target="release/${os}/${arch}" + + echo "Building kontemplate for ${os}-${arch} in ${target}" + + mkdir -p "${target}" + + env GOOS="${os}" GOARCH="${arch}" go build \ + -ldflags "${LDFLAGS}" \ + -o "${target}/kontemplate" \ + -tags netgo + + +} + +function sign-for() { + local os="${1}" + local arch="${2}" + local target="release/${os}/${arch}" + local bin="${target}/kontemplate" + local hash="$(sha256sum ${bin})" + local tar="release/kontemplate-${VERSION}-${os}-${arch}.tar.gz" + + echo "Signing kontemplate binary for ${os}-${arch} with SHA256 ${hash}" + gpg --sign "${bin}" + + echo "Packing release into ${tar}" + tar czvf "${tar}" -C "${target}" kontemplate kontemplate.gpg +} + +case "${1}" in + "build") + # Build releases for various operating systems: + build-for "linux" "amd64" + build-for "darwin" "amd64" + build-for "windows" "amd64" + build-for "freebsd" "amd64" + exit 0 + ;; + "sign") + # Sign releases: + sign-for "linux" "amd64" + sign-for "darwin" "amd64" + sign-for "windows" "amd64" + sign-for "freebsd" "amd64" + exit 0 + ;; +esac |