-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
64 lines (49 loc) · 1.82 KB
/
release.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
#!/bin/sh
if [ "$#" -lt 1 ]; then
echo "Usage: $0 [--force] <EXPORT_NAME> [<GODOT_BIN>]"
exit 1
fi
FORCE_BUILD=false
# Check for the --force parameter
if [ "$1" == "--force" ]; then
FORCE_BUILD=true
shift
fi
EXPORT_NAME="$1"
GODOT_BIN="${2:-godot}"
# Check if the command is available
if ! command -v "$GODOT_BIN" &> /dev/null; then
echo "Error: Godot binary not found at '$GODOT_BIN'"
exit 1
fi
# Check for uncommitted changes or untracked files in the Git workspace
if [ "$FORCE_BUILD" != "true" ] && [ -n "$(git status --porcelain)" ]; then
echo "Error: There are uncommitted changes or untracked files in the Git workspace."
echo "Please commit/stash them before building. Or run the script with --force flag."
exit 1
fi
# Export the game and redirect Godot output to a file
export_game() {
local export_preset="$1"
local output_dir="$2"
local build_name="$3"
local logfile="$output_dir/build.log"
# Get the current date and time
current_datetime=$(date "+%Y-%m-%d %H:%M:%S")
# Get the current Git commit hash (if available)
git_commit=$(git rev-parse --short HEAD 2>/dev/null || echo "No Git commit available")
# Create a log entry with date, time, and Git commit
log_entry="$current_datetime - Git commit: $git_commit"
echo "Building $export_preset..."
# Append the log entry to the build log file
mkdir -p "$output_dir"
touch $logfile
echo "$log_entry" > "$logfile"
$GODOT_BIN --headless --export-release "$export_preset" "$output_dir/$build_name" >> $logfile 2>&1
echo "$export_preset built."
echo
}
export_game "Linux/X11" "builds/$EXPORT_NAME/linux" "$EXPORT_NAME.x86_64"
export_game "macOS" "builds/$EXPORT_NAME/osx" "$EXPORT_NAME.dmg"
export_game "Windows Desktop" "builds/$EXPORT_NAME/windows" "$EXPORT_NAME.exe"
export_game "Web" "builds/$EXPORT_NAME/html5" "index.html"