-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·59 lines (47 loc) · 1.33 KB
/
build.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
#!/bin/bash
cd "${0%/*}" || exit
set -e
image="cowait/task"
notebook="cowait/notebook"
version=$(grep 'version.*=.*".*"' cowait/version.py | sed -E 's/.*"(.*)"/\1/g')
minor=$(echo $version | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/g')
if [ -n "$GITHUB_REF" ]; then
# we are running in a github action
# ensure tag version matches python package version!
github_version=${GITHUB_REF/refs\/tags\//}
if [ "$version" != "$github_version" ]; then
echo "Version missmatch between package ($version) and git tag ($github_version)"
exit 1
fi
fi
args=$*
# build dashboard
if [[ $args == *--with-dashboard* ]]; then
(
cd cloud
yarn install
yarn run build
)
fi
build() {
# build image
echo "Building $1:$version"
docker build --platform linux/amd64 --tag "$1:latest" $2
# tag versions
if [[ $args == *--tag* ]] || [[ $args == *--push* ]]; then
echo "Tag: $1:$version"
docker tag "$1:latest" "$1:$version"
echo "Tag: $1:$minor"
docker tag "$1:latest" "$1:$minor"
fi
# push versions
if [[ $args == *--push* ]]; then
echo "Pushing: $1:latest"
docker push "$1:latest"
echo "Pushing: $1:$version"
docker push "$1:$version"
echo "Pushing: $1:$minor"
docker push "$1:$minor"
fi
}
build $image .