-
Notifications
You must be signed in to change notification settings - Fork 1
/
release
executable file
·112 lines (91 loc) · 2.63 KB
/
release
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
#!/usr/bin/env bash
#
# Prepare MiniZinc or-tools distribution for macOS, Linux, Win64
set -e
prepare_dist() {
dist_name=$1
minizinc_url=$2
or_tools_url=$3
arch=${4-linux}
echo "Creating dist ${dist_name}..."
rm -rf ${dist_name} || true
mkdir -p ${dist_name}
pushd ${dist_name} &>/dev/null
echo "Fetching minizinc..."
extract_here ${minizinc_url} ${arch}
mkdir -p or-tools
pushd or-tools &>/dev/null
echo "Fetching or-tools..."
extract_here ${or_tools_url} ${arch}
echo "Moving or-tools globals..."
mv share/minizinc_cp ../share/minizinc/or-tools
mv bin/* ../bin
mkdir ../share/or-tools
mv LICENSE-2.0.txt ../share/or-tools
popd &>/dev/null
rm -rf or-tools
rm -rf doc
popd &>/dev/null
echo "Creating dist archive..."
create_archive ${arch} ${dist_name} ${dist_name}
mkdir -p vendor
mv ${dist_name} vendor/minizinc
create_archive ${arch} ${dist_name}-vendor vendor
rm -rf vendor
}
extract_here() {
url=$1
arch=$2
case ${arch} in
linux*|darwin)
curl -sSL ${url} | tar --strip-components 1 -xzf -
;;
win*)
tempdir=$(mktemp -d)
pushd ${tempdir} &>/dev/null
curl -sSL ${url} >tmp.zip
unzip -d ${tempdir} -q tmp.zip
popd &>/dev/null
mv ${tempdir}/*/* ./
rm ${tempdir}/tmp.zip
rmdir ${tempdir}/* ${tempdir}
;;
*)
echo "Unknown arch ${arch}."
exit 1
esac
}
create_archive() {
arch=$1
archive_basename=$2
shift; shift
case ${arch} in
linux*|darwin)
tar -czf ${archive_basename}.tar.gz $@
;;
win*)
zip -qr ${archive_basename}.zip $@
;;
*)
echo "Unknown arch ${arch}."
exit 1
esac
}
dist_base=minizinc-2.1.0_or-tools-v5.0
prepare_dist ${dist_base}-darwin \
https://github.com/MiniZinc/libminizinc/releases/download/2.1.0/minizinc-2.1.0-Darwin.tar.gz \
https://github.com/google/or-tools/releases/download/v5.0/or-tools_flatzinc_MacOsX-10.11.6_v5.0.3919.tar.gz
prepare_dist ${dist_base}-linux64 \
https://github.com/MiniZinc/libminizinc/releases/download/2.1.0/minizinc-2.1.0-linux64.tar.gz \
https://github.com/google/or-tools/releases/download/v5.0/or-tools_flatzinc_Ubuntu-14.04-64bit_v5.0.3919.tar.gz
prepare_dist ${dist_base}-win64 \
https://github.com/MiniZinc/libminizinc/releases/download/2.1.0/minizinc-2.1.0-win64.zip \
https://github.com/google/or-tools/releases/download/v5.0/or-tools_flatzinc_VisualStudio2015-64bit_v5.0.3919.zip \
win64
release_cmd="hub release create -m ${dist_base} ${dist_base}"
for asset in ./${dist_base}*; do
release_cmd="${release_cmd} -a ${asset}"
done
echo "Creating release..."
${release_cmd}
echo "Done."