Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHAR build script

This creates a $buildphar as $root/$target/foo.phar + one phar per tag as $root/$target/download/$tag/foo.phar

It also dumps the latest git commit hash built in $root/$target/version

# config
root="/var/www/example.org"
build="project-src"
buildscript="bin/compile"
buildphar="example.phar"
target="web"
repo="https://github.com/example/example.git"
composer="/usr/bin/composer.phar"
# init
if [ ! -d "$root/$build" ]
then
cd $root
git clone $repo $build
fi
cd "$root/$build"
# update master
/usr/bin/git fetch -q origin && \
/usr/bin/git fetch --tags -q origin && \
/usr/bin/git checkout master -q && \
/usr/bin/git rebase origin/master -q && \
/usr/local/bin/php $composer install -q && \
/usr/local/bin/php -d phar.readonly=0 $buildscript && \
mv $buildphar "$root/$target/$buildphar" && \
/usr/bin/git log --pretty="%h" -n1 HEAD > "$root/$target/version"
# create tagged releases
for version in `git tag`; do
if [ ! -f "$root/$target/download/$version/$buildphar" ]
then
mkdir -p "$root/$target/download/$version/"
/usr/bin/git checkout $version -q && \
/usr/local/bin/php $composer install -q && \
/usr/local/bin/php -d phar.readonly=0 $buildscript && \
mv $buildphar "$root/$target/download/$version/$buildphar"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.