forked from workcraft/workcraft
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdist.sh
More file actions
executable file
·112 lines (86 loc) · 2.35 KB
/
dist.sh
File metadata and controls
executable file
·112 lines (86 loc) · 2.35 KB
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
#!/bin/sh -e
plugin_dirs="*Plugin/"
core_dir="WorkcraftCore"
dist_dir="dist"
allplatforms="windows linux osx"
platforms="all"
bname="$(basename $0)"
tag="$(git describe --tags)"
usage() {
cat <<EOF
$bname: create a distribution for Workcraft as workcraft-tag-platform archive
Usage: $bname [platforms] [-t TAG] [-h]
platforms: distribution platforms to build
$allplatforms all (default: all)
-t, --tag TAG: user-defined tag (git tag is used by default)
-h, --help: print this help
EOF
}
err() {
echo "Error: $@" >&2
exit 1
}
# Process parameters
for param in "$@"; do
case "$param" in
-h | --help)
usage
exit 0 ;;
-t | --tag)
tag="$2"
shift 2 ;;
esac
done
if [ ! -e "$core_dir/build" ]; then
err "You need to run './gradlew assemble' first"
fi
if [ -z "$@" ] || [ "$@" = "all" ]; then
platforms="$allplatforms"
else
platforms="$@"
fi
for platform in $platforms; do
if [ "$platform" = "osx" ]; then
dist_rootdir="Workcraft.app"
else
dist_rootdir="workcraft"
fi
dist_name="workcraft-${tag}-${platform}"
dist_path="$dist_dir/$platform/$dist_rootdir"
template_dir="dist-template/$platform"
echo "Building ${dist_name}..."
if [ ! -d "$template_dir" ]; then
err "Template directory not found: $template_dir"
fi
if [ -e "$dist_path" ]; then
err "Distribution directory already exists: $dist_path"
fi
mkdir -p $dist_path
cp -r $template_dir/* $dist_path/
# Set `Resources' as the distribution path on OS X
if [ "$platform" = "osx" ]; then
# Update Info.plist with version tag
sed -i "s/__VERSION__/$tag/" $dist_path/Contents/Info.plist
dist_path=$dist_path/Contents/Resources
fi
cp $core_dir/build/libs/*.jar $dist_path/workcraft.jar
mkdir -p $dist_path/plugins
for d in $plugin_dirs; do
cp $d/build/libs/*.jar $dist_path/plugins/
done
for d in doc/*; do
if [ "$d" != "doc/README.md" ]; then
cp -r $d $dist_path/
fi
done
cd $dist_dir/$platform
case $platform in
windows)
7z a -r ${dist_name}.zip $dist_rootdir >/dev/null
;;
linux | osx)
tar -czf ${dist_name}.tar.gz $dist_rootdir
;;
esac
cd ../..
done