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