2016-08-15 10:45:09 +03:00
|
|
|
#!/usr/bin/env bash
|
2016-08-15 10:52:44 +03:00
|
|
|
set -e
|
2016-08-15 10:45:09 +03:00
|
|
|
|
2021-02-13 14:56:41 +03:00
|
|
|
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ] || ([ "$#" == 2 ] && [ "$2" != "--no-swoole" ]); then
|
2016-08-15 11:18:13 +03:00
|
|
|
echo "Usage:" >&2
|
2021-02-13 14:56:41 +03:00
|
|
|
echo " $0 {version} [--no-swoole]" >&2
|
2016-08-15 11:18:13 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
version=$1
|
2021-02-13 14:56:41 +03:00
|
|
|
noSwoole=$2
|
|
|
|
phpVersion=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;')
|
2022-01-23 13:29:53 +03:00
|
|
|
[[ $noSwoole ]] && swooleSuffix="" || swooleSuffix="_openswoole"
|
2021-02-13 14:56:41 +03:00
|
|
|
distId="shlink${version}_php${phpVersion}${swooleSuffix}_dist"
|
|
|
|
builtContent="./build/${distId}"
|
2016-08-15 10:45:09 +03:00
|
|
|
projectdir=$(pwd)
|
2018-12-16 11:26:08 +03:00
|
|
|
[[ -f ./composer.phar ]] && composerBin='./composer.phar' || composerBin='composer'
|
2016-08-15 10:45:09 +03:00
|
|
|
|
|
|
|
# Copy project content to temp dir
|
|
|
|
echo 'Copying project files...'
|
2021-02-13 14:56:41 +03:00
|
|
|
rm -rf "${builtContent}"
|
|
|
|
mkdir -p "${builtContent}"
|
|
|
|
rsync -av * "${builtContent}" \
|
2019-08-16 19:38:26 +03:00
|
|
|
--exclude=*docker* \
|
2019-08-16 20:30:40 +03:00
|
|
|
--exclude=Dockerfile \
|
2020-03-28 21:54:02 +03:00
|
|
|
--include=.htaccess \
|
2022-08-27 18:48:59 +03:00
|
|
|
--include=config/roadrunner/.rr.yml \
|
2019-08-16 20:30:40 +03:00
|
|
|
--exclude-from=./.dockerignore
|
2021-02-13 14:56:41 +03:00
|
|
|
cd "${builtContent}"
|
2016-08-15 10:45:09 +03:00
|
|
|
|
|
|
|
# Install dependencies
|
2018-09-11 20:17:29 +03:00
|
|
|
echo "Installing dependencies with $composerBin..."
|
2022-08-27 18:51:14 +03:00
|
|
|
composerFlags="--optimize-autoloader --no-progress --no-interaction"
|
2018-09-24 20:35:45 +03:00
|
|
|
${composerBin} self-update
|
2021-02-13 14:56:41 +03:00
|
|
|
${composerBin} install --no-dev --prefer-dist $composerFlags
|
|
|
|
|
|
|
|
if [[ $noSwoole ]]; then
|
2022-01-23 13:29:53 +03:00
|
|
|
# If generating a dist not for openswoole, uninstall mezzio-swoole
|
2021-02-13 14:56:41 +03:00
|
|
|
${composerBin} remove mezzio/mezzio-swoole --with-all-dependencies --update-no-dev $composerFlags
|
2022-08-27 18:48:59 +03:00
|
|
|
else
|
|
|
|
# If generating a dist for openswoole, uninstall RoadRunner
|
|
|
|
${composerBin} remove spiral/roadrunner spiral/roadrunner-jobs --with-all-dependencies --update-no-dev $composerFlags
|
2021-02-13 14:56:41 +03:00
|
|
|
fi
|
2021-01-17 15:03:44 +03:00
|
|
|
|
2016-08-15 10:45:09 +03:00
|
|
|
# Delete development files
|
|
|
|
echo 'Deleting dev files...'
|
|
|
|
rm composer.*
|
|
|
|
|
2018-07-26 19:44:04 +03:00
|
|
|
# Update shlink version in config
|
2018-07-26 21:35:02 +03:00
|
|
|
sed -i "s/%SHLINK_VERSION%/${version}/g" config/autoload/app_options.global.php
|
2018-07-26 19:44:04 +03:00
|
|
|
|
2016-08-15 10:45:09 +03:00
|
|
|
# Compressing file
|
2018-09-11 20:17:29 +03:00
|
|
|
echo 'Compressing files...'
|
2018-09-24 20:35:45 +03:00
|
|
|
cd "${projectdir}"/build
|
2021-02-13 14:56:41 +03:00
|
|
|
rm -f ./${distId}.zip
|
|
|
|
zip -ry ./${distId}.zip ./${distId}
|
2018-09-24 20:35:45 +03:00
|
|
|
cd "${projectdir}"
|
2021-02-13 14:56:41 +03:00
|
|
|
rm -rf "${builtContent}"
|
2018-09-11 20:17:29 +03:00
|
|
|
|
|
|
|
echo 'Done!'
|