made autobuild more portable

This commit is contained in:
Jonas Forsberg 2023-04-17 14:15:21 +02:00
parent a59ae761f3
commit 68f46bd319

View File

@ -1,8 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -aeou pipefail set -aeou pipefail
PACKAGE_NAME="dnsmasq"
BASE_IMAGE="registry.opensuse.org/opensuse/tumbleweed" BASE_IMAGE="registry.opensuse.org/opensuse/tumbleweed"
echo "Pulling latest tumbleweed"
podman pull "${BASE_IMAGE}:latest"
CURRENT_TUMBLEWEED_TAG="$(sed -n 's/.*VERSION=\([0-9]\)/\1/p' Makefile)" 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')" 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')"
@ -12,21 +16,21 @@ if [[ "$CURRENT_TUMBLEWEED_TAG" == "$LATEST_TUMBLEWEED_TAG" ]]; then
fi fi
echo "New tumbleweed image exists" echo "New tumbleweed image exists"
CURRENT_DNSMASQ_VERSION="$(podman run --rm -it ${BASE_IMAGE}:${CURRENT_TUMBLEWEED_TAG} zypper ref > /dev/null && zypper info dnsmasq | sed -n 's/.*Version : \(.*\)$/\1/p')" CURRENT_VERSION="$(podman run --rm -it ${BASE_IMAGE}:${CURRENT_TUMBLEWEED_TAG} /usr/bin/bash -c "zypper ref > /dev/null && zypper info $PACKAGE_NAME | sed -n 's/.*Version : \(.*\)$/\1/p'")"
LATEST_DNSMASQ_VERSION="$(podman run --rm -it ${BASE_IMAGE}:latest zypper ref > /dev/null && zypper info dnsmasq | sed -n 's/.*Version : \(.*\)$/\1/p')" 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'")"
echo "current : $CURRENT_DNSMASQ_VERSION" echo "current : $CURRENT_VERSION"
echo "latest : $LATEST_DNSMASQ_VERSION" echo "latest : $LATEST_VERSION"
if [[ "$CURRENT_DNSMASQ_VERSION" == "$LATEST_DNSMASQ_VERSION" ]]; then if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then
echo "No new dnsmasq version detected" echo "No new $PACKAGE_NAME version detected"
exit 0 exit 0
fi fi
#Updateing Makefile with latest image tag #Updateing Makefile with latest image tag
sed -i 's/VERSION='"$CURRENT_TUMBLEWEED_TAG"'/VERSION='"$LATEST_TUMBLEWEED_TAG"'/' Makefile sed -i 's/VERSION='"$CURRENT_TUMBLEWEED_TAG"'/VERSION='"$LATEST_TUMBLEWEED_TAG"'/' Makefile
git add Makefile git add Makefile
git commit -m "Updated tumpleweed image to $LATEST_TUMBLEWEED_TAG " git commit -m "Updated tumpleweed image to $LATEST_TUMBLEWEED_TAG, $PACKAGE_NAME to $LATEST_VERSION"
git push git push
echo "build and push new image" echo "build and push new image"