mill
author Tomas Zeman <tomas@functionals.cz>
Thu, 29 Apr 2021 09:52:12 +0200
changeset 41 5c3196ebf921
parent 35 b7cfac7cff27
permissions -rwxr-xr-x
Added tag fatags-0.6 for changeset 4979d1ecb377
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     1
#!/usr/bin/env sh
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     2
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     3
# This is a wrapper script, that automatically download mill from GitHub release pages
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     4
# You can give the required mill version with MILL_VERSION env variable
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     5
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
35
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
     6
DEFAULT_MILL_VERSION=0.9.4
27
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     7
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     8
set -e
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     9
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    10
if [ -z "$MILL_VERSION" ] ; then
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    11
  if [ -f ".mill-version" ] ; then
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    12
    MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    13
  elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    14
    MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2)
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    15
  else
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    16
    MILL_VERSION=$DEFAULT_MILL_VERSION
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    17
  fi
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    18
fi
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    19
35
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
    20
if [ "x${XDG_CACHE_HOME}" != "x" ] ; then
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
    21
  MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
    22
else
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
    23
  MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
    24
fi
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
    25
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
27
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    26
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    27
version_remainder="$MILL_VERSION"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    28
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    29
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    30
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    31
if [ ! -x "$MILL_EXEC_PATH" ] ; then
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    32
  mkdir -p $MILL_DOWNLOAD_PATH
35
b7cfac7cff27 mill upgrade 0.5.2 -> 0.9.4
Tomas Zeman <tomas@functionals.cz>
parents: 27
diff changeset
    33
  if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then
27
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    34
    ASSEMBLY="-assembly"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    35
  fi
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    36
  DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    37
  MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    38
  curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    39
  chmod +x "$DOWNLOAD_FILE"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    40
  mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    41
  unset DOWNLOAD_FILE
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    42
  unset MILL_DOWNLOAD_URL
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    43
fi
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    44
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    45
unset MILL_DOWNLOAD_PATH
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    46
unset MILL_VERSION
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    47
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    48
exec $MILL_EXEC_PATH "$@"