forked from codycraven/docker-sassc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·87 lines (81 loc) · 2.42 KB
/
update.sh
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
#!/bin/bash
set -e
cd "$( dirname "${BASH_SOURCE[0]}" )"
for i in "$@"; do
case $i in
--version=*)
VERSION="${i#*=}"
shift # past argument=value
;;
--libsass=*)
LIBSASS_VERSION="${i#*=}"
shift # past argument=value
;;
--sassc=*)
SASSC_VERSION="${i#*=}"
shift # past argument=value
;;
--tag=*)
TAG="${i#*=}"
shift # past argument=value
;;
--namespace=*)
NAMESPACE="${i#*=}"
shift # past argument=value
;;
--help)
echo -e "" \
"SYNOPSIS\n" \
" update.sh OPTIONS\n\n" \
" update.sh --help\n\n" \
"OPTIONS\n" \
" --help\n" \
" Print usage statement \n\n" \
" --version=[x.y], --version=[x.y.z]\n" \
" Specify the semantic version of SassC/LibSass to build from.\n" \
" Also used to determine the path to the Dockerfile and used as\n" \
" the tag.\n\n" \
" --libsass=[x.y], --libsass=[x.y.z]\n" \
" Override the --version of LibSass used to build.\n\n" \
" --sassc=[x.y], --sassc=[x.y.z]\n" \
" Override the --version of SassC used to build.\n\n" \
" --tag=[x.y], --tag=[x.y.z], --tag=[tagname]\n" \
" Specify the semantic version or name to build the image's tag with.\n\n" \
" --namespace=[namespace]\n" \
" Specify the Docker Hub namespace to build the image under." \
| less
exit 0
;;
*)
>&2 echo "Unknown option \"${i#*=}\", try \`update --help\`"
exit 1
;;
esac
done
if [ -z ${VERSION+set} ]; then
>&2 echo "Supply the SassC version desired with --version=x.y.z"
exit 1
fi
VERSION_REGEX="^([0-9]*)\.([0-9]*)(\.([0-9]+((-|.)[^ ]*)?))?$"
if [[ "$VERSION" =~ $VERSION_REGEX ]]; then
MAJOR_VERSION="${BASH_REMATCH[1]}"
MINOR_VERSION="${BASH_REMATCH[2]}"
PATCH_VERSION="${BASH_REMATCH[4]}"
else
>&2 echo "--version must be a semantic version in the format x.y or x.y.z"
exit 1
fi
LIBSASS_VERSION="${LIBSASS_VERSION:-${VERSION}}"
SASSC_VERSION="${SASSC_VERSION:-${VERSION}}"
NAMESPACE="${NAMESPACE:-codycraven}"
if [[ -z ${PATCH_VERSION-unset} ]]; then
TAG="${TAG:-`echo $MAJOR_VERSION.$MINOR_VERSION`}"
else
TAG="${TAG:-`echo $MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION`}"
fi
cd "./$MAJOR_VERSION.$MINOR_VERSION"
docker build \
--build-arg LIBSASS_VERSION="$LIBSASS_VERSION" \
--build-arg SASSC_VERSION="$SASSC_VERSION" \
-t "$NAMESPACE"/sassc:"$TAG" \
.