shlink/build.sh

63 lines
2 KiB
Bash
Raw Normal View History

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
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ] || ([ "$#" == 2 ] && [ "$2" != "--no-swoole" ]); then
echo "Usage:" >&2
echo " $0 {version} [--no-swoole]" >&2
exit 1
fi
version=$1
noSwoole=$2
phpVersion=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;')
2023-06-03 10:08:07 +03:00
# Openswoole is deprecated. Remove in v4.0.0
[[ $noSwoole ]] && swooleSuffix="" || swooleSuffix="_openswoole"
distId="shlink${version}_php${phpVersion}${swooleSuffix}_dist"
builtContent="./build/${distId}"
2016-08-15 10:45:09 +03:00
projectdir=$(pwd)
[[ -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...'
rm -rf "${builtContent}"
mkdir -p "${builtContent}"
rsync -av * "${builtContent}" \
2019-08-16 19:38:26 +03:00
--exclude=*docker* \
--exclude=Dockerfile \
--include=.htaccess \
--include=config/roadrunner/.rr.yml \
--exclude-from=./.dockerignore
cd "${builtContent}"
2016-08-15 10:45:09 +03:00
# Install dependencies
echo "Installing dependencies with $composerBin..."
composerFlags="--optimize-autoloader --no-progress --no-interaction"
${composerBin} self-update
${composerBin} install --no-dev --prefer-dist $composerFlags
if [[ $noSwoole ]]; then
# If generating a dist not for openswoole, uninstall mezzio-swoole
${composerBin} remove mezzio/mezzio-swoole --with-all-dependencies --update-no-dev $composerFlags
else
2023-06-03 10:08:07 +03:00
# Deprecated. Remove in Shlink v4.0.0
# If generating a dist for openswoole, uninstall RoadRunner
2023-04-19 00:22:48 +03:00
${composerBin} remove spiral/roadrunner spiral/roadrunner-jobs spiral/roadrunner-cli spiral/roadrunner-http --with-all-dependencies --update-no-dev $composerFlags
fi
2016-08-15 10:45:09 +03:00
# Delete development files
echo 'Deleting dev files...'
rm composer.*
# Update shlink version in config
sed -i "s/%SHLINK_VERSION%/${version}/g" config/autoload/app_options.global.php
2016-08-15 10:45:09 +03:00
# Compressing file
echo 'Compressing files...'
cd "${projectdir}"/build
rm -f ./${distId}.zip
zip -ry ./${distId}.zip ./${distId}
cd "${projectdir}"
rm -rf "${builtContent}"
echo 'Done!'