Commit 42a8838ea3
Unsigned
Layout: unified · split
build.sh +34 −13
| @@ -1,34 +1,55 @@ | ||
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | # Ensure the latest post is included on the home page | |
| 3 | 4 | printf "Did you update the 'Recent Blog Posts' section? [yn] " |
| 4 | 5 | read answer |
| 5 | 6 | |
| 7 | # Only continue if latest post is included on the home page | |
| 6 | 8 | if [[ "$answer" =~ ^[Yy]$ ]]; then |
| 7 | printf "Publishing on remote or LAN? [r|l] " | |
| 8 | read method | |
| 9 | ||
| 10 | if [[ "$method" =~ ^[Rr]$ ]]; then | |
| 11 | ubuntu_server="ubuntu-remote" | |
| 12 | elif [[ "$method" =~ ^[Ll]$ ]]; then | |
| 13 | ubuntu_server="ubuntu" | |
| 14 | else | |
| 15 | echo "Invalid input. Assuming LAN (ubuntu)" | |
| 16 | ubuntu_server="ubuntu" | |
| 17 | fi | |
| 18 | ||
| 9 | # Check if the environment flag is set to PROD | |
| 19 | 10 | if [[ "$ENV" == "prod" ]]; then |
| 20 | 11 | echo "Environment: Production" |
| 12 | ||
| 13 | # Check if publishing via LAN or remotely | |
| 14 | printf "Publishing on remote or LAN? [r|l] " | |
| 15 | ||
| 16 | # Update ubuntu_server variable based on answer | |
| 17 | read method | |
| 18 | if [[ "$method" =~ ^[Rr]$ ]]; then | |
| 19 | ubuntu_server="ubuntu-remote" | |
| 20 | elif [[ "$method" =~ ^[Ll]$ ]]; then | |
| 21 | ubuntu_server="ubuntu" | |
| 22 | else | |
| 23 | echo "Invalid input. Assuming LAN (ubuntu)" | |
| 24 | ubuntu_server="ubuntu" | |
| 25 | fi | |
| 26 | ||
| 27 | # Remove previous build | |
| 21 | 28 | rm -rf .build/* |
| 29 | ||
| 30 | # Run publishing script | |
| 22 | 31 | emacs --script publish.el &>/dev/null |
| 32 | ||
| 33 | # Minify CSS | |
| 23 | 34 | minify -o theme/static/styles.min.css theme/static/styles.css |
| 35 | ||
| 36 | # Deploy changes | |
| 24 | 37 | rsync -r --delete-before .build/* $ubuntu_server:/var/www/cleberg.net/ |
| 25 | 38 | else |
| 26 | 39 | echo "Environment: Development" |
| 40 | ||
| 41 | # Remove previous build | |
| 27 | 42 | rm -rf .build/* |
| 43 | ||
| 44 | # Run publishing script | |
| 28 | 45 | emacs --script publish.el |
| 46 | ||
| 47 | # Minify CSS | |
| 29 | 48 | minify -o theme/static/styles.min.css theme/static/styles.css |
| 49 | ||
| 50 | # Launch development web server | |
| 30 | 51 | cd .build/ |
| 31 | python3 -m http.server | |
| 52 | python3 -m http.server | |
| 32 | 53 | fi |
| 33 | 54 | else |
| 34 | 55 | echo "Please update the 'Recent Blog Posts' section before publishing!" |