aboutsummaryrefslogtreecommitdiff
path: root/build.sh
blob: 2998612a23f04da6b49d72ad236e9dc3b2e3c50d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash

# Ensure the latest post is included on the home page
printf "Did you update the 'Recent Blog Posts' section? [yn] "
read answer

# Only continue if latest post is included on the home page
if [[ "$answer" =~ ^[Yy]$ ]]; then
    # Check if the environment flag is set to PROD
    if [[ "$ENV" == "prod" ]]; then
        echo "Environment: Production"
        
        # Check if publishing via LAN or remotely
        printf "Publishing on remote or LAN? [r|l] "
        
        # Update ubuntu_server variable based on answer
        read method
        if [[ "$method" =~ ^[Rr]$ ]]; then
            ubuntu_server="ubuntu-remote"
        elif [[ "$method" =~ ^[Ll]$ ]]; then
            ubuntu_server="ubuntu"
        else
            echo "Invalid input. Assuming LAN (ubuntu)"
            ubuntu_server="ubuntu"
        fi
        
        # Remove previous build
        rm -rf .build/*
        
        # Run publishing script
        emacs --script publish.el &>/dev/null
        
        # Minify CSS
        minify -o theme/static/styles.min.css theme/static/styles.css

        # Update README on Sourcehut
        pandoc -f org -t html readme.org  -o readme.html
		hut git update --readme readme.html --repo https://git.sr.ht/\~cyborg/cleberg.net
        
        # Deploy changes
        rsync -r --delete-before .build/* $ubuntu_server:/var/www/cleberg.net/
    else
        echo "Environment: Development"
        
        # Remove previous build
        rm -rf .build/*
        
        # Run publishing script
        emacs --script publish.el
        
        # Minify CSS
        minify -o theme/static/styles.min.css theme/static/styles.css

        # Launch development web server
        cd .build/
        python3 -m http.server
    fi
else
    echo "Please update the 'Recent Blog Posts' section before publishing!"
fi