shlink/build.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

2016-08-15 02:45:09 -05:00
#!/usr/bin/env bash
2016-08-15 02:52:44 -05:00
set -e
2016-08-15 02:45:09 -05:00
2024-02-12 13:29:40 -06:00
if [ "$#" -lt 1 ]; then
echo "Usage:" >&2
2024-02-12 13:29:40 -06:00
echo " $0 {version}" >&2
exit 1
fi
version=$1
phpVersion=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;')
2024-02-12 13:29:40 -06:00
distId="shlink${version}_php${phpVersion}_dist"
builtContent="./build/${distId}"
2016-08-15 02:45:09 -05:00
projectdir=$(pwd)
[[ -f ./composer.phar ]] && composerBin='./composer.phar' || composerBin='composer'
2016-08-15 02:45:09 -05:00
# Copy project content to temp dir
echo 'Copying project files...'
rm -rf "${builtContent}"
mkdir -p "${builtContent}"
rsync -av * "${builtContent}" \
2019-08-16 11:38:26 -05:00
--exclude=*docker* \
--exclude=Dockerfile \
--include=.htaccess \
--include=config/roadrunner/.rr.yml \
--exclude-from=./.dockerignore
cd "${builtContent}"
2016-08-15 02:45:09 -05:00
# Install dependencies
echo "Installing dependencies with $composerBin..."
${composerBin} self-update
2024-02-12 13:29:40 -06:00
${composerBin} install --no-dev --prefer-dist --optimize-autoloader --no-progress --no-interaction
2016-08-15 02:45:09 -05:00
# Delete development files
echo 'Deleting dev files...'
rm composer.*
2024-10-24 01:49:58 -05:00
# Update Shlink version
sed -i "s/%SHLINK_VERSION%/${version}/g" module/Core/src/Config/Options/AppOptions.php
2016-08-15 02:45:09 -05: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!'