Laravel pre-distribution cleanup and package!!

Laravel pre-distribution clean up and package to zip project excluding files that don’t need to be shipped

  1. You can create a file called deploy on your Linux system or Windows using git bash.
  2. In Linux, make it executable.
  3. Check that you have zip package installed in Linux
  4. Copy the contents to deploy.
  5. When ready to zip your file run ./deploy on your terminal. This will create a zip file in your target directory with version number and name of the file. If an older version already exists, it will create an incremental version by 1.
#This program automates creating a clean archive for public release of
#Laravel framework based application. For security, you will need to append .env-example to your final zip archive.
#For Windows with Ubuntu sub-system, create a .bat file called deploy.bat and append ./laravel-deploy.bash. 
#Then you can click on the .bat to run deployment script.
# The format of the final filename is "v1" increments to v2 and so forth in consequent runs.

#Target filename

#Target directory with no trailing slash!

echo $(php artisan view:clear)
echo $(php artisan config:clear)
echo $(php artisan route:clear)
echo $(php artisan clear-compiled)
echo $(php artisan cache:clear)
echo $(composer dump-autoload)

echo "Testing target directory..."

if [ -d "$path" ]
    echo "Found target directory!"
    echo "Creating target directory"
    mkdir -p "$path"

echo Reading current versions
ls "$path"

#read -p "Would you like to include Laravel assets? " -n 1 -r
# echo
# if [[ $REPLY =~ ^[Yy]$ ]]
# then
#     assets=""
# else
#     #exclude if no add "$assets$ after -x on zip command below
#     assets="resources/assets/"
# fi

fileName=$(find "$path" -type f -name "$name-*.zip")
array=( $fileName )
echo "Echo current versions is: $currentVer"

echo "Echo new version is: $newVer"

find storage/framework/sessions ! -name '.gitignore' -type f -exec rm {} +
rm -rf storage/debugbar
rm -df public/storage
rm -rf bash.exe.stackdump npm-debug.log storage/logs/laravel.log composer.lock

touch storage/logs/laravel.log

now=$(date +"%m-%d-%Y")

zip -r "$path$name-$now-v$" * -x "*.git*" "*.idea*" "*node_modules/*" "*vendor/*" "zip.bash" "deploy.bat" "npm-debug.log" ".env"