Permalink
Browse files

rework management binaries

  • Loading branch information...
1 parent a0b37b2 commit 2537839f34cfc99ad25d7a45869aa4f817e306c5 @ddollar committed Jul 14, 2012
Showing with 139 additions and 75 deletions.
  1. +44 −0 bin/build
  2. +0 −75 bin/deploy
  3. +51 −0 bin/release
  4. +44 −0 bin/upload
View
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+#/ Usage: build <environment>
+#/
+#/ build anvil using the anvil-<build> app
+#/
+#/ slug url will be output to stdout
+#/ build output will be output to stderr
+
+# fail fast
+set -o errexit
+set -o pipefail
+
+echo() {
+ /bin/echo $*
+}
+
+error() {
+ /bin/echo $*; exit 1
+}
+
+check_env() {
+ [[ ${!1} ]] || error "Environment variable ${1} is not set."
+}
+
+usage() {
+ cat $0 | grep '^#/' | cut -c4-
+}
+
+while getopts "h" opt; do
+ case $opt in
+ h) usage; exit 0 ;;
+ ?) usage; exit 0 ;;
+ esac
+done
+
+root=$(dirname $(dirname $0))
+build_environment=$1
+
+if [ "$build_environment" == "" ]; then
+ error "Must specify a build environment."
+fi
+
+env ANVIL_HOST="https://anvil-${build_environment}.herokuapp.com" heroku build $root -p
View
@@ -1,75 +0,0 @@
-#!/bin/bash
-#
-#/ Usage: deploy [-b]
-#/
-#/ -b Recompile the compiler using itself before deploying
-
-ANVIL_PRODUCTION="https://anvil.herokuapp.com"
-ANVIL_STAGING="https://anvil-staging.herokuapp.com"
-
-echo() {
- /bin/echo $*
-}
-
-error() {
- /bin/echo $*; exit 1
-}
-
-# make sure we have the right env vars
-check_env() {
- [[ ${!1} ]] || error "Environment variable ${1} is not set."
-}
-
-usage() {
- cat $0 | grep '^#/' | cut -c4-
-}
-
-root=$(dirname $(dirname $0))
-
-# fail fast
-set -o errexit
-set -o pipefail
-
-bootstrap=""
-
-while getopts "hb" opt; do
- case $opt in
- b) bootstrap="1"; ;;
- h) usage; exit 0 ;;
- ?) usage; exit 0 ;;
- esac
-done
-
-check_env AWS_ACCESS
-check_env AWS_SECRET
-check_env S3_BUCKET
-
-echo -n "Creating build using old compiler... "
-build=$(env ANVIL_HOST=${ANVIL_PRODUCTION} heroku build $root -p 2>$root/log/deploy.log)
-echo "done"
-
-echo -n "Releasing new compiler to staging... "
-heroku release $build -a anvil-staging >$root/log/deploy.log
-echo "done"
-
-if [ "bootstrap" == "1" ]; then
- echo -n "Creating build using new compiler that was built with old compiler... "
- build=$(env ANVIL_HOST=${ANVIL_STAGING} heroku build $root -p 2>$root/log/deploy.log)
- heroku release $build -a anvil-staging >$root/log/deploy.log
- echo "done"
-
- echo -n "Creating build using new compiler that was built with new compiler... "
- build=$(env ANVIL_HOST=${ANVIL_STAGING} heroku build $root -p 2>$root/log/deploy.log)
- heroku release $build -a anvil-staging >$root/log/deploy.log
- echo "done"
-fi
-
-echo -n "Releasing new compiler to production... "
-heroku release $build -a anvil >$root/log/deploy.log
-echo "done"
-
-echo -n "Uploading build to S3... "
-downloaded=$(mktemp -t build_XXXXX)
-curl -s $build -o $downloaded
-$root/bin/s3 put $downloaded /software/production/anvil.img >/dev/null 2>&1
-echo "done"
View
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+#/ Usage: release <environment> <slug_url>
+#/
+#/ release <slug_url> to anvil-<environment>
+#/ use - for <slug_url> to read from stdin
+#/
+#/ release id will be output to stdout
+
+
+# fail fast
+set -o errexit
+set -o pipefail
+
+echo() {
+ /bin/echo $*
+}
+
+error() {
+ /bin/echo $*; exit 1
+}
+
+usage() {
+ cat $0 | grep '^#/' | cut -c4-
+}
+
+while getopts "h" opt; do
+ case $opt in
+ h) usage; exit 0 ;;
+ ?) usage; exit 0 ;;
+ esac
+done
+
+environment=$1
+slug_url=$2
+
+if [ "$environment" == "" ]; then
+ error "Must specify a release environment."
+fi
+
+if [ "$slug_url" == "-" ]; then
+ read slug_url
+fi
+
+if [ "$slug_url" == "" ]; then
+ error "Must specify a slug url."
+fi
+
+echo -n "Releasing ${slug_url} to anvil-${environment}..."
+heroku release $slug_url -a anvil-$environment >&2
+echo "done"
View
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+#/ Usage: upload <slug_url>
+#/
+#/ upload the slug_url to s3 as permanent storage
+
+# fail fast
+set -o errexit
+set -o pipefail
+
+echo() {
+ /bin/echo $*
+}
+
+error() {
+ /bin/echo $*; exit 1
+}
+
+check_env() {
+ [[ ${!1} ]] || error "Environment variable ${1} is not set."
+}
+
+usage() {
+ cat $0 | grep '^#/' | cut -c4-
+}
+
+while getopts "h" opt; do
+ case $opt in
+ h) usage; exit 0 ;;
+ ?) usage; exit 0 ;;
+ esac
+done
+
+check_env AWS_ACCESS
+check_env AWS_SECRET
+check_env S3_BUCKET
+
+root=$(dirname $(dirname $0))
+
+echo -n "Uploading ${slug_url} to S3... "
+downloaded=$(mktemp -t build_XXXXX)
+curl -s $slug_url -o $downloaded
+$root/bin/s3 put $downloaded /software/production/anvil.img >/dev/null 2>&1
+echo "done"

0 comments on commit 2537839

Please sign in to comment.