-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcompile_all.sh
executable file
·134 lines (113 loc) · 4.45 KB
/
compile_all.sh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# Check if the current directory path ends with "rvbbit"
if [[ "${PWD}" != */rvbbit ]]; then
echo "Error: This script must be run from the rvbbit root source directory."
echo "Current directory: ${PWD}"
exit 1
fi
# If we're here, we're safe-ish.
BUILD_NUMBER=0
BUILD_NUMBER_FILE="build_number.txt"
if [ -f "$BUILD_NUMBER_FILE" ]; then
BUILD_NUMBER=$(cat "$BUILD_NUMBER_FILE")
fi
# Increment the build number
BUILD_NUMBER=$((BUILD_NUMBER + 1))
# Save the new build number
echo "$BUILD_NUMBER" > "$BUILD_NUMBER_FILE"
BUILD_ID=$(date +%s)
BUILD_DATE=$(date '+%Y-%m-%d %H:%M:%S')
echo "(ns rvbbit-frontend.build-id) (def build-id \"$BUILD_ID\") (def build-date \"$BUILD_DATE\") (def build-number $BUILD_NUMBER)" > frontend/src/rvbbit_frontend/build_id.cljs
echo "(ns rvbbit-backend.build-id) (def build-id \"$BUILD_ID\") (def build-date \"$BUILD_DATE\") (def build-number $BUILD_NUMBER)" > backend/src/rvbbit_backend/build_id.clj
export LEIN_SNAPSHOTS_IN_RELEASE=true ## for now, until we have a better build process. besides, most of the snapshot deps are mine.
draw_bordered_text() {
local BRIGHT_CYAN="\e[1;96m"
local BOLD_BRIGHT_PINK="\e[1;95m"
local RESET="\e[0m"
local text="$1"
local text_width=${#text}
local total_width=$((text_width + 6))
local border=$(printf "%0.s#" $(seq 1 $total_width))
echo -e "${BRIGHT_CYAN}${border}${RESET}"
echo -e "${BRIGHT_CYAN}## ${RESET}${BOLD_BRIGHT_PINK}${text}${RESET}${BRIGHT_CYAN} ##${RESET}"
echo -e "${BRIGHT_CYAN}${border}${RESET}"
}
cd frontend
./clean-me.sh
draw_bordered_text "Cleaning, pulling deps, compiling UI..."
npm install
rm -rf .shadow-cljs
npx shadow-cljs release app
draw_bordered_text "UI compiled. copying to server resources"
cd ..
rm -rf backend/resources/public/
rm frontend/resources/public/assets
cp -r frontend/resources/public backend/resources/public
rm -rf backend/resources/public/images/gen/
rm -rf backend/resources/public/images/large/
draw_bordered_text "UI copied. compiling uberjar."
cd backend
mkdir target -p
mkdir db -p
mkdir data/atoms -p
# ls ./target/*.jar -l -h
lein clean
lein uberjar
ls ./target/*.jar -l -h
find ./target -name "rvbbit*standalone.jar" -exec cp {} rvbbit.jar \;
VERSION=$(grep -m1 'defproject' project.clj | sed 's/^[^"]*"//' | sed 's/".*//')
##VERSION=${VERSION%.*}
DIR_NAME="rvbbit-$VERSION"
rm -rf "../$DIR_NAME"
mkdir -p "../$DIR_NAME"
draw_bordered_text "creating release... $DIR_NAME"
cp -r assets "../$DIR_NAME/assets"
cp -r connections "../$DIR_NAME/connections"
cp -r data "../$DIR_NAME/data"
mkdir -p "../$DIR_NAME/db"
cp -r defs "../$DIR_NAME/defs"
cp -r ai-workers "../$DIR_NAME/ai-workers"
mv "../$DIR_NAME/defs/empty-secrets.edn" "../$DIR_NAME/defs/secrets.edn"
cp -r flows "../$DIR_NAME/flows"
cp -r themes "../$DIR_NAME/themes"
cp -r extras "../$DIR_NAME/extras"
cp -r resources "../$DIR_NAME/resources"
cp -r screens "../$DIR_NAME/screens"
cp user.clj "../$DIR_NAME/"
cp run-rabbit.sh "../$DIR_NAME/"
cp rvbbit.jar "../$DIR_NAME/"
## my dev repo has lots of things in gitignore - but still present locally. wont apply to fresh clones.
rm -rf ../docker-staging
rm -rf "../$DIR_NAME/assets/data-exports"
rm -rf "../$DIR_NAME/assets/snaps"
rm -rf "../$DIR_NAME/data/atoms"
rm -rf "../$DIR_NAME/defs/backup"
rm -f "../$DIR_NAME/defs/secrets.edn"
rm -rf "../$DIR_NAME/extras/node-colorthief/node_modules"
rm "../$DIR_NAME/extras/node-colorthief/package-lock.json"
mkdir -p "../$DIR_NAME/data/atoms"
mkdir -p "../$DIR_NAME/assets/data-exports"
## due to docker "layering" I cannot remove files once added to a layer, so I have to pre-remove them here first
## also only applies to local dev repo, not fresh clones.
mkdir -p ../docker-staging
rm -rf "../$DIR_NAME.zip"
## zip -rq "../$DIR_NAME.zip" "../$DIR_NAME/"
(cd .. && zip -rq "$DIR_NAME.zip" "$DIR_NAME")
cd "../$DIR_NAME"
cp -r * ../docker-staging/
cd ../backend
echo ""
cat data/nname.ans
echo ""
draw_bordered_text "done. go to ./backend/ or ./$DIR_NAME/ and run ./run-rabbit.sh, then visit localhost:8888"
echo ""
# link back so shadow-cljs can see server assets w/o pedestal routes
cd ../frontend/resources/public
ln -s ../../../backend/assets assets
cd ../../../
# draw_bordered_text "building Docker image..."
# cd ..
# docker build --no-cache -t rvbbit .
# docker run -d -p 8888:8888 -p 3030:3030 -p 8181:8181 -v rvbbit-root:/app/ rvbbit
# docker pull ghcr.io/ryrobes/rvbbit:latest
# docker run -d -p 8888:8888 -p 3030:3030 -p 8181:8181 -v rvbbit-root2:/app/ ghcr.io/ryrobes/rvbbit:latest