Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Commit

Permalink
feat release: Add simple release script
Browse files Browse the repository at this point in the history
Adds a simple script that will build stripped binaries for various platforms
and GPG-sign them.
  • Loading branch information
tazjin committed May 8, 2017
1 parent d93bc51 commit 1e3ecad
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
release/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ to only update the `api` resource sets and the `frontend/user-page` resource set

Assuming you have Go configured correctly, you can simply `go get github.com/tazjin/kontemplate/...`.

There are signed binary releases available on the [releases page][] for Linux, OS X and Windows.
There are signed binary releases available on the [releases page][] for Linux, OS X,
FreeBSD and Windows.

## Usage

Expand Down
57 changes: 57 additions & 0 deletions build-release.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1e3ecad

Please sign in to comment.