-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_upload.sh
executable file
·96 lines (77 loc) · 2.03 KB
/
build_and_upload.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
#!/bin/bash
# Script to automatically build and deploy project to an rclone directory
# Requires the following commands: rclone, 7z, tar
# Also requires path to godot client, preferrably headless. This needs to be changed to match your configuration.
print_usage()
{
echo "Usage: $0 [-w for windows | -l for linux]"
}
build_linux()
{
echo Cleaning up Linux bin folder...
mkdir -p bin/linux
rm -f bin/linux/*
echo Building Linux...
/opt/godot-headless --quiet --export "Linux/X11" bin/linux/dungeon_masters.x86_64
echo Archiving Linux...
tar cfJ bin/linux/linux.tar.xz -C bin/linux/ dungeon_masters.x86_64 dungeon_masters.pck
echo Uploading Linux...
rclone copy --update bin/linux/linux.tar.xz google-drive:"Dungeon Masters/bin"
}
build_windows()
{
echo Cleaning up Windows bin folder...
mkdir -p bin/windows
rm -f bin/windows/*
echo Building Windows...
/opt/godot-headless --quiet --export "Windows Desktop" bin/windows/dungeon_masters.exe
echo Archiving Windows...
7z a bin/windows/windows.7z bin/windows/dungeon_masters.exe bin/windows/dungeon_masters.pck > /dev/null
echo Uploading Windows...
rclone copy --update bin/windows/windows.7z google-drive:"Dungeon Masters/bin"
}
# Check prerequisites
if ! command -v rclone >/dev/null 2>&1; then
echo "ERROR: Missing package: rclone"
exit 1
fi
if ! command -v 7z >/dev/null 2>&1; then
echo "ERROR: Missing package: 7z"
exit 1
fi
if ! command -v tar >/dev/null 2>&1; then
echo "ERROR: Missing package: tar"
exit 1
fi
if [ ! -f "project.godot" ]; then
echo "ERROR: Script must be run from a directory containing a project.godot file"
exit 1
fi
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
while getopts "wlh" opt; do
case "${opt}" in
w)
build_windows
;;
l)
build_linux
;;
h)
print_usage
exit 0
;;
*)
print_usage >&2
exit 1
;;
esac
done
# Remove just flags processed from $@
shift $((OPTIND-1))
# If no arguments passed
if [ $OPTIND -eq 1 ]; then
print_usage >&2
exit 1
fi
echo Done.