forked from bb-Ricardo/netbox-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.publi.sh
executable file
·42 lines (34 loc) · 1.31 KB
/
.publi.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
#!/usr/bin/env bash
IMAGE_NAME="bbricardo/netbox-sync"
IMAGE_PLATFORM="linux/arm/v7,linux/arm64/v8,linux/amd64"
IMAGE_PLATFORM="linux/amd64" # currently only amd64 due to too many dependencies when installing vmware python sdk
IMAGE_TAG=$(grep "^__version__" netbox-sync.py | sed 's/__version__ = "\(.*\)"/\1/g')
if [[ -z "$IMAGE_TAG" ]]; then
echo "ERROR: unable to grep version from 'netbox-sync.py'"
exit 1
fi
read -rp "Is '$IMAGE_TAG' a beta (b) release or final (f) release: " -n1 ANSWER && echo
[[ $ANSWER =~ [bB] ]] && FINAL=false
[[ $ANSWER =~ [fF] ]] && FINAL=true
[[ -z "${FINAL+default}" ]] && echo "Please select 'b' or 'f'." && exit 1
unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
find . -name "__pycache__" -delete
docker --config ./docker-tmp login
docker --config ./docker-tmp buildx create --use
if [[ $FINAL == true ]]; then
docker --config ./docker-tmp buildx build --push \
--platform ${IMAGE_PLATFORM} \
--tag "${IMAGE_NAME}:latest" \
--tag "${IMAGE_NAME}:${IMAGE_TAG}" .
# shellcheck disable=SC2181
[[ ${?} -ne 0 ]] && exit 1
which docker-pushrm >/dev/null 2>&1 && docker-pushrm ${IMAGE_NAME}:latest
else
docker --config ./docker-tmp buildx build --push \
--platform ${IMAGE_PLATFORM} \
--tag "${IMAGE_NAME}:${IMAGE_TAG}" .
fi
rm -rf ./docker-tmp
# EOF