| author | Tomas Zeman <tomas@functionals.cz> |
| Tue, 24 Nov 2020 10:49:12 +0100 | |
| changeset 30 | 12cda49d6c84 |
| permissions | -rwxr-xr-x |
|
30
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env sh |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
2 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
3 |
# This is a wrapper script, that automatically download mill from GitHub release pages |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
4 |
# You can give the required mill version with MILL_VERSION env variable |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
5 |
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
6 |
DEFAULT_MILL_VERSION=0.7.4 |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
7 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
8 |
set -e |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
9 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
10 |
if [ -z "$MILL_VERSION" ] ; then |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
11 |
if [ -f ".mill-version" ] ; then |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
12 |
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
13 |
elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
14 |
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
15 |
else |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
16 |
MILL_VERSION=$DEFAULT_MILL_VERSION |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
17 |
fi |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
18 |
fi |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
19 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
20 |
if [ "x${XDG_CACHE_HOME}" != "x" ] ; then
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
21 |
MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
22 |
else |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
23 |
MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
24 |
fi |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
25 |
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
26 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
27 |
version_remainder="$MILL_VERSION" |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
28 |
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
29 |
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
30 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
31 |
if [ ! -x "$MILL_EXEC_PATH" ] ; then |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
32 |
mkdir -p $MILL_DOWNLOAD_PATH |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
33 |
if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
34 |
ASSEMBLY="-assembly" |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
35 |
fi |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
36 |
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
37 |
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}"
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
38 |
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
39 |
chmod +x "$DOWNLOAD_FILE" |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
40 |
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
41 |
unset DOWNLOAD_FILE |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
42 |
unset MILL_DOWNLOAD_URL |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
43 |
fi |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
44 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
45 |
unset MILL_DOWNLOAD_PATH |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
46 |
unset MILL_VERSION |
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
47 |
|
|
12cda49d6c84
SQWL#2016 - Project build update
Tomas Zeman <tomas@functionals.cz>
parents:
diff
changeset
|
48 |
exec $MILL_EXEC_PATH "$@" |