Skip to content

Commit

Permalink
Add release automation scripts.
Browse files Browse the repository at this point in the history
Also fixes error in Makefile where the sha256sum executable name was assumed.

Scripts added to make and upload builds locally using Docker images for each
supported platform.
  • Loading branch information
Travis B. Hartwell committed Jan 4, 2017
1 parent 1d7fe05 commit dee0b4c
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ tarball-standalone: rel
mkdir -p packages
tar -C rel -czf $(PKGNAME) $(REPO)/
mv $(PKGNAME) packages/
cd packages && shasum -a 256 $(PKGNAME) > $(PKGNAME).sha
cd packages && $(SHASUM) $(PKGNAME) > $(PKGNAME).sha
cd packages && echo "$(DOWNLOAD_BASE)" > remote.txt
cd packages && echo "$(BASE_DIR)/packages/$(PKGNAME)" > local.txt
sync-standalone:
Expand Down
66 changes: 66 additions & 0 deletions admin/build-release-task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

if [ "$#" -ne 1 ]; then
>&2 echo "Usage $0 OS_NAME"
exit 1
fi

REX_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"

case $1 in
"centos-7")
ERLANG_TARBALL=https://basholabs.artifactoryonline.com/basholabs/build/centos-7/erlang/OTP_R16B02_basho10/erlang-OTP_R16B02_basho10.tgz
export OS_FAMILY=centos
export OS_VERSION=7
;;

"debian-8")
ERLANG_TARBALL=https://basholabs.artifactoryonline.com/basholabs/build/debian-8/erlang/OTP_R16B02_basho10/erlang-OTP_R16B02_basho10.tgz
export OS_FAMILY=debian
export OS_VERSION=8
;;

"ubuntu-14.04")
ERLANG_TARBALL=https://basholabs.artifactoryonline.com/basholabs/build/ubuntu-14.04/erlang/OTP_R16B02_basho10/erlang-OTP_R16B02_basho10.tgz
export OS_FAMILY=ubuntu
export OS_VERSION=14.04
;;

"osx")
export OS_FAMILY=osx
export OS_VERSION=10.11
;;

*)
>&2 echo "Unsupported OS"
exit 1
;;
esac

if [ "osx" != "${OS_FAMILY}" ]; then
if [ -z "${ERLANG_TARBALL}" ]; then
>&2 echo "Shouldn't get here, ERLANG_TARBALL variable should be set"
exit 1
fi

# Download and install Erlang
mkdir -p /usr/lib/erlang
cd /usr/lib/erlang
curl -O -Ssl "${ERLANG_TARBALL}"
tar xf erlang-OTP_R16B02_basho10.tgz

# Add Erlang to the PATH
export PATH=$PATH:/usr/lib/erlang/bin
else
# Assumes Erlang is installed via KERL in ~/erlang
. ~/erlang/R16B02/activate
fi

# Make erlang build
cd "${REX_DIR}"
make tarball
make reltarball
make tarball-standalone
make sync
make relsync
make sync-standalone
53 changes: 53 additions & 0 deletions admin/build-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

# Capture the output of all of the commands
OUTPUT_LOG=/tmp/riak_explorer_build.out
OUTPUT_PIPE=/tmp/riak_explorer_build-output.pipe

if [ ! -e ${OUTPUT_PIPE} ]; then
mkfifo ${OUTPUT_PIPE}
fi

if [ -e ${OUTPUT_LOG} ]; then
rm ${OUTPUT_LOG}
fi

exec 3>&1 4>&2
tee ${OUTPUT_LOG} < ${OUTPUT_PIPE} >&3 &
tpid=$!
exec > ${OUTPUT_PIPE} 2>&1

REX_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
REX_ADMIN_SCRIPTS_DIR="${REX_DIR}"/admin

# Make sure the oath token exists
if [ ! -e "${REX_DIR}"/oauth.txt ]; then
>&2 echo "Github OAUTH token required in ${REX_DIR}/oauth.txt"
exit 1
fi

declare -a OS_NAMES
OS_NAMES=( centos-7 debian-8 ubuntu-14.04 )

# Make sure latest image is pulled
for os in "${OS_NAMES[@]}"; do
docker pull basho/build-essential:"${os}" | grep -E "^Status"
done

# Run the build in container for each OS
for os in "${OS_NAMES[@]}"; do
docker run --rm -it \
-v ${REX_DIR}:/riak_explorer \
basho/build-essential:"${os}" \
/riak_explorer/admin/build-release-task.sh "${os}"
done

# Also run the build locally for macOS
if [ "$(uname)" == "Darwin" ]; then
${REX_ADMIN_SCRIPTS_DIR}/build-release-task.sh osx
fi

exec 1>&3 3>&- 2>&4 4>&-
wait ${tpid}

rm ${OUTPUT_PIPE}
51 changes: 48 additions & 3 deletions docs/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

## Requirements

1. MacOSX machine
2. Ubuntu 14.04 machine
3. CentOS 7 machine
1. macOS machine
2. Either:
a. Docker on macOS or
b. Ubuntu 14.04 machine
CentOS 7 machine
Debian 8 machine
4. Github oauth token

## Tag
Expand All @@ -22,8 +25,39 @@ cd riak_explorer
echo "YOUR_OAUTH_TOKEN" > oauth.txt
```

If you are working from a local copy, make sure you have run the following after
creating the release on Github to get the tag:

```
git pull --tags --all
```

## Build and Upload

We have release automation scripts in the [admin](../admin) directory. If you
run the main `build-release.sh` script in that directory, it will build and
upload the release for each of the following platforms:

* OS X
* CentOS 7
* Debian 8
* Ubuntu 14.04

The Linux releases will be done in Docker, using
the [basho/build-essential](https://hub.docker.com/r/basho/build-essential/)
Docker image.

This assumes Erlang is installed on OS X
via [kerl](https://github.com/kerl/kerl) and is found in `~/erlang/R16B02`.

Kick off the build by doing the following:

```
./admin/build-release.sh
```

If you wish to do this by hand on each machine, do the following:

* OSX

```
Expand Down Expand Up @@ -57,6 +91,17 @@ OS_FAMILY=centos OS_VERSION=7 make relsync
OS_FAMILY=centos OS_VERSION=7 make sync-standalone
```

* Debian

```
OS_FAMILY=debian OS_VERSION=8 make tarball
OS_FAMILY=debian OS_VERSION=8 make reltarball
OS_FAMILY=debian OS_VERSION=8 make tarball-standalone
OS_FAMILY=debian OS_VERSION=8 make sync
OS_FAMILY=debian OS_VERSION=8 make relsync
OS_FAMILY=debian OS_VERSION=8 make sync-standalone
```

## Verify

1. Navigate to https://github.com/basho-labs/riak_explorer/releases/tag/YOUR_TAG
Expand Down

0 comments on commit dee0b4c

Please sign in to comment.