mill
author Tomas Zeman <tomas@functionals.cz>
Thu, 24 Oct 2019 08:52:17 +0200
changeset 30 8933b942e89f
parent 27 c4534300acdc
child 35 b7cfac7cff27
permissions -rwxr-xr-x
fatags: 0.5-SNAPSHOT -> 0.5
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
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     6
DEFAULT_MILL_VERSION=0.5.2
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
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    20
MILL_DOWNLOAD_PATH="$HOME/.mill/download"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    21
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    22
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    23
version_remainder="$MILL_VERSION"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    24
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
    25
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
    26
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    27
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
    28
  mkdir -p $MILL_DOWNLOAD_PATH
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    29
  if [ $MILL_MAJOR_VERSION -gt 0 ] || [ $MILL_MINOR_VERSION -ge 5 ] ; then
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    30
    ASSEMBLY="-assembly"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    31
  fi
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    32
  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
    33
  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
    34
  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
    35
  chmod +x "$DOWNLOAD_FILE"
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    36
  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
    37
  unset DOWNLOAD_FILE
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    38
  unset MILL_DOWNLOAD_URL
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    39
fi
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    40
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    41
unset MILL_DOWNLOAD_PATH
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    42
unset MILL_VERSION
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    43
c4534300acdc Mill upgrade -> 0.5.2, using PublishM2Module, fixed project urls
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    44
exec $MILL_EXEC_PATH "$@"