forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
earth
executable file
·38 lines (28 loc) · 951 Bytes
/
earth
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
#!/bin/bash
set -e
bindir="$HOME/.earthly"
if [ ! -d "$bindir" ]; then
mkdir -p "$bindir"
fi
last_check_state_path=/tmp/last-earth-prerelease-check
get_latest_binary() {
docker rm --force earthly_binary 2>/dev/null || true
docker pull earthly/buildkitd:prerelease
docker pull earthly/earthlybinaries:prerelease
docker create --name earthly_binary earthly/earthlybinaries:prerelease
earth_bin_path=/earth-linux-amd64
if [ "$(uname)" == "Darwin" ]; then
earth_bin_path=/earth-darwin-amd64
fi
docker cp earthly_binary:"$earth_bin_path" "$bindir/earth-prerelease"
docker rm earthly_binary
}
last=$(cat "$last_check_state_path" 2>/dev/null || echo 0)
now=$(date +%s)
since=$(( now - last ))
if [ "$since" -ge 3600 ] && [ -z "$COMP_LINE" ]; then
echo checking for latest earth pre-release binaries
get_latest_binary
echo "$now" >"$last_check_state_path"
fi
"$bindir/earth-prerelease" "$@"