Skip to content

Commit

Permalink
Add bin/release script
Browse files Browse the repository at this point in the history
Summary:
- Add bin/release script
- Patch bin/update changes from docker branch

Test Plan:
Run `bin/release 3.0.0-beta.11`
Run `tar -tzf build/Ushahidi-Platform-v3.0.0-beta.11.tar.gz ` to check what was in the built tarball

Reviewers: aMoniker, vladimir

Differential Revision: https://phabricator.ushahidi.com/D636
  • Loading branch information
rjmackay committed Jan 22, 2015
1 parent 29db051 commit d43f4cb
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 13 deletions.
76 changes: 76 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

# if someone invokes this with bash
set -e

# build release tarball
usage() {
echo usage: $0 VERSION
exit 2
}

test $# -eq 1 || usage
VERSION=$1
CWD=$(pwd)

TMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t platform-build)
WORK_DIR=$TMP_DIR/ushahidi-platform
mkdir $WORK_DIR

echo "Copy to temp dir"
cp -R ./ $WORK_DIR

pushd $WORK_DIR

echo "Clean out extra files"
git clean -fdx

echo "Running bin/update --production"
bin/update --production --no-migrate

popd
pushd $TMP_DIR

# Tar it up.
echo "Building tarball"
mkdir -p "${CWD}/build"
TARFILE="${CWD}/build/Ushahidi-Platform-${VERSION}.tar"

tar -cf $TARFILE \
--exclude 'application/cache' \
--exclude 'application/logs' \
--exclude 'application/media/uploads' \
--exclude 'application/config/environments' \
--exclude 'application/routes' \
--exclude '.htaccess' \
--exclude 'build' \
--exclude 'application/tests' \
--exclude 'spec' \
--exclude '.phpspec' \
--exclude '.travis.yml' \
--exclude '.librarian' \
--exclude '.vagrant' \
--exclude '.tmp' \
--exclude 'composer.*' \
--exclude 'phpspec.yml.dist' \
--exclude 'behat.yml.dist' \
--exclude 'phpunit.xml.dist' \
--exclude '.arc*' \
--exclude '.git' \
--exclude '.git*' \
ushahidi-platform/

# Add extra file that would have been excluded otherwise
tar -rf $TARFILE \
'ushahidi-platform/application/cache/.gitignore' \
'ushahidi-platform/application/logs/.gitignore' \
'ushahidi-platform/application/media/uploads/.gitignore' \
'ushahidi-platform/application/config/environments/development/.gitignore' \
'ushahidi-platform/application/routes/default.php'

gzip -f $TARFILE
echo "Release tarball: `pwd`/${TARFILE}.gz"

popd

rm -rf $TMP_DIR
35 changes: 22 additions & 13 deletions bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ fi
# Defaults
production=false
withgit=false
installdeps=true
migrate=true

# Parse options
# Based on code from http://mywiki.wooledge.org/ComplexOptionParsing
optspec=":h-:"
Expand All @@ -34,8 +37,14 @@ while true; do
production)
production=true
;;
no-deps)
installdeps=false
;;
no-migrate)
migrate=false
;;
h|help)
echo "usage: $0 [--git-update] [--production]" >&2
echo "usage: $0 [--git-update] [--production] [--no-migrate] [--no-deps]" >&2
exit 2
;;
esac
Expand All @@ -55,8 +64,7 @@ else
fi

composer="composer"
migrate="$(dirname "$0")/phinx"
upgrade=1
phinx="$(dirname "$0")/phinx"

# Check required commands are available
which $composer >/dev/null 2>&1
Expand All @@ -68,25 +76,26 @@ if [ $? -gt 0 ]; then
fi
fi

if [ -n "$" -a "$1" == "migrate" ]; then
upgrade=0
fi

# Deployment mode, disable all developer dependencies :)
if [ "$production" = true ]; then
echo ">>> Skipping development dependencies"
composer="$composer --no-dev"
npm="$npm --production"
fi

if [ $upgrade -gt 0 ]; then
if [ "$installdeps" = true ]; then
echo ">>> Updating dependencies"
$composer install
else
echo ">>> Skipping installing all dependencies"
fi

if [ -f "$migrate" ]; then
echo ">>> Running migrations"
$migrate migrate -c application/phinx.php
if [ "$migrate" = true ]; then
if [ -f "$phinx" ]; then
echo ">>> Running migrations"
$phinx migrate -c application/phinx.php
else
echo "!!! Migration tool $migrate not installed, unable to run migrations"
fi
else
echo "!!! Migration tool $migrate not installed, unable to run migrations"
echo ">>> Skipping running migrations"
fi

0 comments on commit d43f4cb

Please sign in to comment.