-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpublish
executable file
·50 lines (38 loc) · 1007 Bytes
/
publish
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
#!/usr/bin/env bash
#
# Usage:
# publish
#
# This program publishes the cyverse/irods image on Dockerhub. Each build is
# tagged with `new`.
set -o errexit -o nounset -o pipefail
EXEC_DIR="$(dirname "$(realpath --canonicalize-existing "$0")")"
readonly EXEC_DIR
readonly IMAGE_NAME=cyverse/irods
readonly NEW_IMAGE="$IMAGE_NAME":new
readonly CUR_IMAGE="$IMAGE_NAME":latest
main() {
local irodsVer
IFS= read -r irodsVer < "$EXEC_DIR"/VERSION
local newId
newId="$(docker image inspect "$NEW_IMAGE" | jq .[0].Id)"
local curId
if docker pull "$IMAGE_NAME" 2> /dev/null; then
curId="$(docker image inspect "$CUR_IMAGE" 2> /dev/null | jq .[0].Id)" || true
fi
if [[ "$newId" != "${curId-}" ]]; then
local now
now="$(date --utc '+%Y-%m-%dT%H-%M-%S')"
local tag
for tag in "$irodsVer"_"$now" "$irodsVer" latest; do
publish "$tag"
done
fi
}
publish() {
local tag="$1"
local imageTag="$IMAGE_NAME":"$tag"
docker tag "$NEW_IMAGE" "$imageTag"
docker push "$imageTag"
}
main "$@"