-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-version.sh
More file actions
executable file
·24 lines (20 loc) · 929 Bytes
/
Copy pathget-version.sh
File metadata and controls
executable file
·24 lines (20 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
export IMG=$(docker build -q --pull --no-cache -t 'get-version' .)
export RADICALE_VERSION=$(docker run --rm -t get-version pip3 list | grep -i radicale | tr ' ' '\n' | grep '[0-9]\.[0-9]' | tr -d '\r')
export ALPINE_VERSION=$(docker run --rm -t get-version cat /etc/alpine-release | tail -n1 | tr -d '\r')
[ -z "$ALPINE_VERSION" ] && exit 1
export IMGTAG=$(echo "$1""a$ALPINE_VERSION-r$RADICALE_VERSION")
# FORCE_REBUILD (set by the workflow for push / manual runs) rebuilds even if
# the versioned image already exists, so code/config changes get republished.
# the nightly schedule leaves it unset and keeps deduping on the version tag.
if [ -n "$FORCE_REBUILD" ]; then
echo "$IMGTAG"
exit 0
fi
export IMAGE_EXISTS=$(docker pull "$IMGTAG" 2>/dev/null >/dev/null; echo $?)
# return latest, if container is already available :)
if [ "$IMAGE_EXISTS" -eq 0 ]; then
echo "$1""latest"
else
echo "$IMGTAG"
fi