dnsmasq/autobuild.sh

40 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2023-04-17 07:59:57 +00:00
#!/usr/bin/env bash
set -aeou pipefail
BASE_IMAGE="registry.opensuse.org/opensuse/tumbleweed"
TARGET_REPO="git.rre.nu/jonas/"
PACKAGE_NAME="dnsmasq"
2023-04-17 07:59:57 +00:00
2023-04-17 12:15:21 +00:00
echo "Pulling latest tumbleweed"
podman pull "${BASE_IMAGE}:latest"
2023-04-17 07:59:57 +00:00
CURRENT_TUMBLEWEED_TAG="$(sed -n 's/.*VERSION=\([0-9]\)/\1/p' Makefile)"
LATEST_TUMBLEWEED_TAG="$(podman image inspect --format "{{.Labels}}" registry.opensuse.org/opensuse/tumbleweed:latest | sed -n 's/.*org\.opencontainers\.image\.version:\([0-9]\{8\}\).*/\1/p')"
if [[ "$CURRENT_TUMBLEWEED_TAG" == "$LATEST_TUMBLEWEED_TAG" ]]; then
echo "Already running latest tumbleweed version"
exit 0
fi
echo "New tumbleweed image exists"
CURRENT_VERSION="$(podman run --rm -it ${TARGET_REPO}${PACKAGE_NAME}:latest /usr/bin/bash -c "zypper info $PACKAGE_NAME | sed -n 's/.*Version : \(.*\)$/\1/p'")"
2023-04-17 12:15:21 +00:00
LATEST_VERSION="$(podman run --rm -it ${BASE_IMAGE}:latest /usr/bin/bash -c "zypper ref > /dev/null && zypper info $PACKAGE_NAME | sed -n 's/.*Version : \(.*\)$/\1/p'")"
2023-04-17 07:59:57 +00:00
2023-04-17 12:15:21 +00:00
echo "current : $CURRENT_VERSION"
echo "latest : $LATEST_VERSION"
2023-04-17 07:59:57 +00:00
2023-04-17 12:15:21 +00:00
if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then
echo "No new $PACKAGE_NAME version detected"
2023-04-17 07:59:57 +00:00
exit 0
fi
#Updateing Makefile with latest image tag
sed -i 's/VERSION='"$CURRENT_TUMBLEWEED_TAG"'/VERSION='"$LATEST_TUMBLEWEED_TAG"'/' Makefile
git add Makefile
2023-04-17 12:15:21 +00:00
git commit -m "Updated tumpleweed image to $LATEST_TUMBLEWEED_TAG, $PACKAGE_NAME to $LATEST_VERSION"
2023-04-17 07:59:57 +00:00
git push
echo "build and push new image"
make release