2017-12-14 07:03:59 +08:00
#!/usr/bin/env bash
2017-12-14 07:38:12 +08:00
if [ " $TRAVIS " = "true" ] ; then
2017-12-14 07:03:59 +08:00
2018-02-04 03:16:37 +08:00
cd $TRAVIS_BUILD_DIR
2017-12-14 07:38:12 +08:00
if test " $TRAVIS_TAG " ; then
PKG_NAME = $TRAVIS_TAG
else
2018-02-04 03:39:39 +08:00
echo " On branch $TRAVIS_BRANCH "
2018-02-04 03:50:08 +08:00
2018-02-04 03:55:55 +08:00
if [ " $TRAVIS_BRANCH " != "master" ] && [ " $TRAVIS_BRANCH " != "dev" ] ; then
2018-02-04 03:50:08 +08:00
echo "Not on valid branch, exiting"
exit 0;
fi ;
2018-02-04 03:16:37 +08:00
BASE_VERSION = ` php artisan phpvms:version --base-only`
2018-02-04 03:39:39 +08:00
PKG_NAME = ${ BASE_VERSION } -${ TRAVIS_BRANCH }
2017-12-14 07:38:12 +08:00
fi
2017-12-14 07:25:14 +08:00
2018-02-03 05:20:21 +08:00
FILE_NAME = " phpvms- $PKG_NAME "
2018-01-20 21:50:10 +08:00
TAR_NAME = " $FILE_NAME .tar.gz "
2017-12-15 01:02:29 +08:00
echo " Writing $TAR_NAME "
2017-12-14 07:31:58 +08:00
2018-01-07 07:00:47 +08:00
php artisan phpvms:version --write > VERSION
2018-01-05 11:45:45 +08:00
VERSION = ` cat VERSION`
echo " Version: $VERSION "
2018-01-05 05:17:55 +08:00
2018-02-03 05:39:53 +08:00
echo "Cleaning files"
2018-02-04 03:16:37 +08:00
2018-08-21 00:24:32 +08:00
rm -rf vendor
composer install --no-dev --prefer-dist --no-interaction --verbose
2018-01-05 03:58:38 +08:00
2018-08-21 00:24:32 +08:00
# Clean up the dependencies to remove some of the dev packages
# declare -a remove_packages=(
# 'barryvdh/laravel-ide-helper'
# 'bpocallaghan/generators'
# 'codedungeon/phpunit-result-printer'
# 'fzaninotto/faker'
# 'nikic/php-parser'
# 'phpstan/phpstan'
# 'phpunit/phpunit',
# 'weebly/phpstan-laravel'
# )
#
# for pkg in "${remove_packages[@]}"
# do
# composer --optimize-autoloader --no-interaction remove $pkg
# done
2018-01-05 05:17:55 +08:00
2018-08-20 23:39:44 +08:00
# Leftover individual files to delete
declare -a remove_files = (
.git
.sass-cache
.idea
.travis
2018-09-10 22:25:45 +08:00
tests
_ide_helper.php
2018-08-20 23:39:44 +08:00
.dpl
2018-09-10 22:25:45 +08:00
.eslintignore
.eslintrc
2018-08-20 23:39:44 +08:00
.phpstorm.meta.php
2018-09-10 22:25:45 +08:00
.styleci.yml
2018-08-20 23:39:44 +08:00
env.php
config.php
2018-08-21 00:24:32 +08:00
Makefile
2018-08-20 23:39:44 +08:00
phpunit.xml
phpvms.iml
Procfile
phpstan.neon
node_modules
composer.phar
vendor/willdurand/geocoder/tests
)
for file in " ${ remove_files [@] } "
do
rm -rf $file
done
2017-12-29 07:45:57 +08:00
2018-08-21 00:24:32 +08:00
find ./vendor -type d -name ".git" -print0 | xargs rm -rf
find . -type d -name "sass-cache" -print0 | xargs rm -rf
# clear any app specific stuff that might have been loaded in
find storage/app -mindepth 1 -not -name '.gitignore' -not -name public -not -name import -print0 -exec rm -rf { } +
2018-08-21 01:01:13 +08:00
find storage/app/public -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/framework/cache -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/framework/sessions -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/framework/views -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/logs -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
2018-08-21 00:24:32 +08:00
2018-05-06 23:01:02 +08:00
make clean
2018-08-20 23:39:44 +08:00
echo "Creating Tarball"
2017-12-18 02:18:11 +08:00
cd /tmp
2018-01-05 05:22:32 +08:00
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR /../ phpvms
2018-02-03 05:39:53 +08:00
sha256sum $TAR_NAME > " $TAR_NAME .sha256 "
2017-12-14 07:25:14 +08:00
2018-08-20 23:39:44 +08:00
echo "Uploading to S3"
2018-02-03 05:39:53 +08:00
mkdir -p $TRAVIS_BUILD_DIR /build
cd $TRAVIS_BUILD_DIR /build
mv " /tmp/ $TAR_NAME " " /tmp/ $TAR_NAME .sha256 " .
2018-01-20 22:11:53 +08:00
artifacts upload --target-paths "/" $TAR_NAME $TRAVIS_BUILD_DIR /VERSION $TAR_NAME .sha256
2018-01-05 11:45:45 +08:00
2018-03-27 04:07:24 +08:00
# Upload the version for a tagged release. Move to a version file in different
# tags. Within phpVMS, we have an option of which version to track in the admin
if test " $TRAVIS_TAG " ; then
2018-08-20 23:39:44 +08:00
echo "Uploading release version file"
2018-03-27 04:20:25 +08:00
cp " $TRAVIS_BUILD_DIR /VERSION " release_version
artifacts upload --target-paths "/" release_version
2018-03-27 04:07:24 +08:00
else
2018-08-20 23:39:44 +08:00
echo " Uploading ${ TRAVIS_BRANCH } _version file "
2018-03-27 04:26:47 +08:00
cp $TRAVIS_BUILD_DIR /VERSION ${ TRAVIS_BRANCH } _version
artifacts upload --target-paths "/" ${ TRAVIS_BRANCH } _version
2018-03-27 04:07:24 +08:00
fi
2018-01-17 14:15:37 +08:00
curl -X POST --data " {\"content\": \"A new build is available at http://downloads.phpvms.net/ $TAR_NAME ( $VERSION )\"} " -H "Content-Type: application/json" $DISCORD_WEBHOOK_URL
2017-12-14 07:25:14 +08:00
fi