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
2019-12-12 01:57:18 +08:00
cd $TRAVIS_BUILD_DIR
2018-02-04 03:16:37 +08:00
2019-12-12 01:57:18 +08:00
if test " $TRAVIS_TAG " ; then
PKG_NAME = $TRAVIS_TAG
VERSION = $TRAVIS_TAG
2018-02-04 03:50:08 +08:00
2019-12-12 01:57:18 +08:00
# Pass in the tag as the version to write out
php artisan phpvms:version --write $VERSION
else
echo " On branch $TRAVIS_BRANCH "
2018-02-04 03:50:08 +08:00
2019-12-12 01:57:18 +08:00
if [ " $TRAVIS_BRANCH " != "master" ] && [ " $TRAVIS_BRANCH " != "dev" ] ; then
echo "Not on valid branch, exiting"
exit 0
2017-12-14 07:38:12 +08:00
fi
2017-12-14 07:25:14 +08:00
2019-12-12 04:12:31 +08:00
# Write the version out but place the branch ID in there
# This is only for the dev branch
2019-12-12 01:57:18 +08:00
BASE_VERSION = $( php artisan phpvms:version --base-only)
2019-12-12 04:12:31 +08:00
# This now includes the pre-release version, so "-dev" by default
PKG_NAME = ${ BASE_VERSION }
2017-12-14 07:31:58 +08:00
2019-12-12 01:57:18 +08:00
# Don't pass in a version here, just write out the latest hash
2019-12-12 04:12:31 +08:00
php artisan phpvms:version --write >VERSION
2019-08-30 20:08:00 +08:00
VERSION = $( cat VERSION)
2019-12-12 01:57:18 +08:00
fi
echo " Version: $VERSION "
2019-12-12 04:12:31 +08:00
echo " Package name: $TAR_NAME "
2019-12-12 01:57:18 +08:00
FILE_NAME = " phpvms- $PKG_NAME "
TAR_NAME = " $FILE_NAME .tar.gz "
2020-02-10 23:40:42 +08:00
ZIP_NAME = " $FILE_NAME .zip "
2019-12-12 01:57:18 +08:00
echo "Cleaning files"
rm -rf vendor
composer install --no-dev --prefer-dist --no-interaction --verbose
# Leftover individual files to delete
declare -a remove_files = (
.git
.github
.sass-cache
.idea
.travis
docker
_ide_helper.php
2020-01-17 00:49:22 +08:00
.dockerignore
2019-12-12 01:57:18 +08:00
.dpl
.editorconfig
.eslintignore
.eslintrc
.php_cs
.php_cs.cache
.phpstorm.meta.php
.styleci.yml
.phpunit.result.cache
env.php
intellij_style.xml
config.php
docker-compose.yml
Makefile
phpcs.xml
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
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 bootstrap/cache -mindepth 1 -maxdepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/app -mindepth 1 -maxdepth 1 -not -name '.gitignore' -not -name public -not -name import -print0 -exec rm -rf { } +
find storage/app/public -mindepth 1 -maxdepth 1 -not -name '.gitignore' -not -name avatars -not -name uploads -print0 -exec rm -rf { } +
find storage/app/public/avatars -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/app/public/uploads -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/debugbar -mindepth 1 -not -name '.gitignore' -print0 -exec rm -rf { } +
find storage/docker -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 { } +
mkdir -p storage/app/public/avatars
mkdir -p storage/app/public/uploads
mkdir -p storage/framework/cache
mkdir -p storage/framework/sessions
mkdir -p storage/framework/views
# Regenerate the autoloader and classes
composer dump-autoload
make clean
cd /tmp
2020-02-11 04:10:06 +08:00
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR /../
2019-12-12 01:57:18 +08:00
sha256sum $TAR_NAME >" $TAR_NAME .sha256 "
2020-02-11 01:39:59 +08:00
tar2zip $TAR_NAME
2020-02-10 23:40:42 +08:00
2020-02-11 01:54:59 +08:00
ls -al /tmp
2019-12-12 01:57:18 +08:00
echo "Uploading to S3"
mkdir -p $TRAVIS_BUILD_DIR /build
cd $TRAVIS_BUILD_DIR /build
2020-02-11 01:39:59 +08:00
mv " /tmp/ $TAR_NAME " " /tmp/ $ZIP_NAME " " /tmp/ $TAR_NAME .sha256 " .
2020-02-11 02:01:13 +08:00
artifacts upload --target-paths "/" $ZIP_NAME $TAR_NAME $TRAVIS_BUILD_DIR /VERSION $TAR_NAME .sha256
2019-12-12 01:57:18 +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
echo "Uploading release version file"
cp " $TRAVIS_BUILD_DIR /VERSION " release_version
artifacts upload --target-paths "/" release_version
else
echo " Uploading ${ TRAVIS_BRANCH } _version file "
cp $TRAVIS_BUILD_DIR /VERSION ${ TRAVIS_BRANCH } _version
artifacts upload --target-paths "/" ${ TRAVIS_BRANCH } _version
fi
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