| author | Tomas Zeman <tomas@functionals.cz> |
| Tue, 31 Jan 2023 20:47:44 +0100 | |
| changeset 17 | 4245abe80f45 |
| parent 11 | 4d14b8c6fe87 |
| permissions | -rwxr-xr-x |
| 0 | 1 |
#!/usr/bin/env sh |
2 |
||
3 |
# This is a wrapper script, that automatically download mill from GitHub release pages |
|
4 |
# You can give the required mill version with MILL_VERSION env variable |
|
5 |
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION |
|
6 |
||
7 |
set -e |
|
8 |
||
|
17
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
9 |
if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
|
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
10 |
DEFAULT_MILL_VERSION=0.10.10 |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
11 |
fi |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
12 |
|
| 0 | 13 |
if [ -z "$MILL_VERSION" ] ; then |
14 |
if [ -f ".mill-version" ] ; then |
|
15 |
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" |
|
|
17
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
16 |
elif [ -f ".config/mill-version" ] ; then |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
17 |
MILL_VERSION="$(head -n 1 .config/mill-version 2> /dev/null)" |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
18 |
elif [ -f "mill" ] && [ "$0" != "mill" ] ; then |
| 0 | 19 |
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) |
20 |
else |
|
21 |
MILL_VERSION=$DEFAULT_MILL_VERSION |
|
22 |
fi |
|
23 |
fi |
|
24 |
||
| 11 | 25 |
if [ "x${XDG_CACHE_HOME}" != "x" ] ; then
|
26 |
MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
|
|
27 |
else |
|
28 |
MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
|
|
29 |
fi |
|
30 |
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
|
|
31 |
||
32 |
version_remainder="$MILL_VERSION" |
|
33 |
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
|
|
34 |
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
|
|
| 0 | 35 |
|
|
17
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
36 |
if [ ! -s "$MILL_EXEC_PATH" ] ; then |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
37 |
mkdir -p "$MILL_DOWNLOAD_PATH" |
| 11 | 38 |
if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then |
39 |
ASSEMBLY="-assembly" |
|
40 |
fi |
|
| 0 | 41 |
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download |
|
17
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
42 |
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
43 |
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}"
|
| 0 | 44 |
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" |
45 |
chmod +x "$DOWNLOAD_FILE" |
|
46 |
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" |
|
47 |
unset DOWNLOAD_FILE |
|
48 |
unset MILL_DOWNLOAD_URL |
|
49 |
fi |
|
50 |
||
|
17
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
51 |
if [ -z "$MILL_MAIN_CLI" ] ; then |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
52 |
MILL_MAIN_CLI="${0}"
|
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
53 |
fi |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
54 |
|
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
55 |
MILL_FIRST_ARG="" |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
56 |
if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
57 |
# Need to preserve the first position of those listed options |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
58 |
MILL_FIRST_ARG=$1 |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
59 |
shift |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
60 |
fi |
|
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
61 |
|
| 0 | 62 |
unset MILL_DOWNLOAD_PATH |
63 |
unset MILL_VERSION |
|
64 |
||
|
17
4245abe80f45
Scala update, support for 2.13. Dependencies / mill update.
Tomas Zeman <tomas@functionals.cz>
parents:
11
diff
changeset
|
65 |
exec $MILL_EXEC_PATH $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"
|