-
-
Save simensen/97c0668ac44818a93230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Copyright (C) 2012 Dragonfly Development Inc. | |
# | |
[email protected]:sculpin/sculpin.git | |
BUILD_DIR=build | |
LATEST=master | |
AS=master | |
while [ $# -gt 0 ] | |
do | |
case "$1" in | |
(--local) LOCAL=yes;; | |
(--release) | |
if [ $# -gt 1 ] | |
then | |
RELEASE="$2"; AS="$2"; shift | |
else | |
echo "$0: error - no release specified for option $1" 1>&2 | |
exit 1 | |
fi | |
;; | |
(--latest) | |
if [ $# -gt 1 ] | |
then | |
LATEST="$2"; AS="$2"; shift | |
else | |
echo "$0: error - no release specified for option $1" 1>&2 | |
exit 1 | |
fi | |
;; | |
(--remote-url) | |
if [ $# -gt 1 ] | |
then | |
REMOTE_URL="$2"; shift | |
else | |
echo "$0: error - no URL specified for option $1" 1>&2 | |
exit 1 | |
fi | |
;; | |
(--as) | |
if [ $# -gt 1 ] | |
then | |
AS="$2"; shift | |
else | |
echo "$0: error - no name specified for option $1" 1>&2 | |
exit 1 | |
fi | |
;; | |
(--) shift; break;; | |
esac | |
shift | |
done | |
REMOTE_NAME=$(echo "$REMOTE_URL" | git hash-object --stdin) | |
if [ -z "$AS" ] | |
then | |
AS="$LATEST" | |
fi | |
if [ ! -e "$BUILD_DIR" ] | |
then | |
mkdir -p "$BUILD_DIR" | |
fi | |
if [ ! -e "$BUILD_DIR/.git" ] | |
then | |
( cd "$BUILD_DIR"; git init . ) | |
fi | |
pushd "$BUILD_DIR" | |
if ! git remote | grep "^${REMOTE_NAME}$" >/dev/null | |
then | |
git remote add "$REMOTE_NAME" "$REMOTE_URL" | |
fi | |
git remote update "$REMOTE_NAME" | |
git fetch "$REMOTE_NAME" "+refs/tags/*:refs/tags/${REMOTE_NAME}/*" | |
if [ -n "$RELEASE" ] | |
then | |
git checkout -B "$AS" "$REMOTE_NAME/$LATEST" | |
elif [ -n "$LATEST" ] | |
then | |
git checkout -B "$AS" "$REMOTE_NAME/$LATEST" | |
fi | |
composer install -o --no-dev | |
rm -f sculpin.phar | |
box build | |
mkdir -p out | |
cp sculpin.phar out/ | |
pushd out | |
php sculpin.phar --version | |
php sculpin.phar --git-version > ../version | |
rm sculpin.phar | |
popd | |
rm -rf out | |
if [ "master" = "$AS" ] | |
then | |
scp -P 668 sculpin.phar [email protected]:/opt/dflydev/websites/download.sculpin.io/shared/docroot/sculpin.phar | |
scp -P 668 version [email protected]:/opt/dflydev/websites/download.sculpin.io/shared/docroot/version | |
fi | |
if [ -n "$RELEASE" ] | |
then | |
scp -P 668 sculpin.phar [email protected]:/opt/dflydev/websites/download.sculpin.io/shared/docroot/release/$RELEASE/sculpin.phar | |
elif [ -n "$LATEST" ] | |
then | |
scp -P 668 sculpin.phar [email protected]:/opt/dflydev/websites/download.sculpin.io/shared/docroot/latest/$AS/sculpin.phar | |
fi | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment