-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdockerhub.sh
executable file
·73 lines (62 loc) · 1.76 KB
/
dockerhub.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
#!/bin/bash
# Ensure a platform is provided
if [ -z "$1" ]; then
echo "Error: No distribution provided."
exit 1
fi
# Ensure a version is provided
if [ -z "$2" ]; then
echo "Error: No platform provided."
exit 1
fi
# Ensure a version is provided
if [ -z "$3" ]; then
echo "Error: No version provided."
exit 1
fi
DISTRIBUTION=$1
PLATFORM=$2
FULL_VERSION=$3
SPLIT=(${FULL_VERSION//./ })
MAJOR=${SPLIT[0]}
MINOR=${SPLIT[1]:-0} # set to 0 if no minor version is provided
PATCH=${SPLIT[2]:-0} # set to 0 if no patch version is provided
# Validate MAJOR, MINOR, and PATCH to ensure they are numeric
if ! [[ "$MAJOR" =~ ^[0-9]+$ ]]; then
echo "Error: MAJOR version is not a number."
exit 1
fi
if ! [[ "$MINOR" =~ ^[0-9]+$ ]]; then
echo "Error: MINOR version is not a number."
exit 1
fi
if ! [[ "$PATCH" =~ ^[0-9]+$ ]]; then
echo "Error: PATCH version is not a number."
exit 1
fi
echo "Building for $DISTRIBUTION on $PLATFORM"
# Construct the tags
if [ "$DISTRIBUTION" == "debian" ]; then
TAGS="--tag tagoio/relay \
--tag tagoio/relay:${DISTRIBUTION} \
--tag tagoio/relay:${MAJOR}.${MINOR} \
--tag tagoio/relay:${MAJOR}.${MINOR}.${PATCH} \
--tag tagoio/relay:bookworm \
--tag tagoio/relay:${MAJOR}.${MINOR}-bookworm \
--tag tagoio/relay:${MAJOR}.${MINOR}.${PATCH}-bookworm"
elif [ "$DISTRIBUTION" == "alpine" ]; then
TAGS="--tag tagoio/relay:${DISTRIBUTION} \
--tag tagoio/relay:${MAJOR}.${MINOR}-${DISTRIBUTION} \
--tag tagoio/relay:${MAJOR}.${MINOR}.${PATCH}-${DISTRIBUTION}"
else
echo "Error: Unknown distribution."
exit 1
fi
# Display the tags
echo "Tags to be used: $TAGS"
cd build
docker buildx build --push --build-arg TAGORELAY_VERSION=${FULL_VERSION} \
--file Dockerfile.${DISTRIBUTION} \
--platform ${PLATFORM} \
$TAGS \
.