-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·60 lines (43 loc) · 1.06 KB
/
build.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
#!/bin/bash
echo -e "### Setting up environment..."
set -e
# shellcheck disable=SC2034
NODE_ENV=production
PACKAGE_MANAGER="yarn"
set +e
if ! command -v yarn &>/dev/null; then
PACKAGE_MANAGER="npm"
fi
set -e
echo -e "### Building frontend...\n"
(
cd client
$PACKAGE_MANAGER install
$PACKAGE_MANAGER run build
)
echo -e "\n### Cleaning backend...\n"
if [ -f server/constants/bin/gpo ]; then
rm server/constants/bin/gpo
fi
echo -e "\n### Building backend...\n"
(
cd server
$PACKAGE_MANAGER install --production
)
echo -e "\n### Parsing repo status..."
set +e
GIT_TAG="$(git tag -l --points-at HEAD | head -1)"
GIT_COMMIT="$(git rev-parse HEAD | cut -c 1-7)"
GIT_REF=$GIT_TAG
if [[ $GIT_REF == "" ]]; then
GIT_REF="$GIT_COMMIT"
fi
GIT_DIRTY=""
if ! git diff-index --quiet HEAD; then
GIT_DIRTY="_dirty"
fi
set -e
echo -e "### Bundling assets..."
ARCHIVE_NAME="./dashpodder_${GIT_REF}${GIT_DIRTY}.tar.gz"
tar -czf "$ARCHIVE_NAME" --transform 's/^\.\//dashpodder\//' ./client/dist ./server
echo -e "\n### Assets archived in: ${ARCHIVE_NAME} !"