7 Commits

Author SHA1 Message Date
Jonas Forsberg
10a2ad7b39 added image labels 2023-04-18 14:20:21 +02:00
2bd8d77b20 check installed verson of dnsmasq in target image 2023-04-18 10:26:28 +02:00
Jonas Forsberg
62ad3b85fe changed to gitea image repo 2023-04-17 19:50:21 +02:00
Jonas Forsberg
8064d08c58 more verbose tag message 2023-04-17 14:20:39 +02:00
Jonas Forsberg
68f46bd319 made autobuild more portable 2023-04-17 14:15:21 +02:00
Jonas Forsberg
a59ae761f3 added latest tag in release 2023-04-17 10:17:50 +02:00
Jonas Forsberg
bcc246d345 added first autobuild 2023-04-17 09:59:57 +02:00
2 changed files with 59 additions and 6 deletions

View File

@@ -2,9 +2,11 @@
-include .env
VERSION=20230411
VERSION=20230416
IMAGENAME=dnsmasq
REPO=docker.io/bardak
REPO=git.rre.nu/jonas
TITLE=dnsmasq based on openSUSE Tumpleweed
DESC=Image containing dnsmasq, based on openSUSE Tumbleweed
SHELL := /bin/bash
@@ -22,15 +24,27 @@ require_clean_git:
exit 1; \
fi
build:
podman build --build-arg VERSION=$(VERSION) --tag ${REPO}/${IMAGENAME}:$(VERSION) .
podman build \
--build-arg VERSION="$(VERSION)" \
--label org.opencontainers.image.source="https://${REPO}/${IMAGENAME}/src/tag/v${VERSION}" \
--label org.opencontainers.image.title="${TITLE}" \
--label org.opencontainers.image.description="${DESC}" \
--label org.opencontainers.image.created="$(shell TZ=UTC date --iso-8601=ns)" \
--label org.opencontainers.image.url="https://${REPO}/-/packages/container/${IMAGENAME}/${VERSION}" \
--label org.opencontainers.image.version="${VERSION}" \
--label org.opencontainers.image.vendor="Jonas Forsberg" \
--tag ${REPO}/${IMAGENAME}:$(VERSION) \
.
clean:
podman image rm ${REPO}/${IMAGENAME}:$(VERSION)
release: require_clean_git build
$(eval TMP_MESSAGE := $(shell podman run --rm -it ${REPO}/${IMAGENAME}:$(VERSION) /usr/sbin/dnsmasq --version))
git tag -a v$(VERSION) -m "${TMP_MESSAGE}"
git tag -a v$(VERSION) -m "dnsmasq version: ${TMP_MESSAGE}"
git push origin v$(VERSION)
podman push --creds $(USERNAME):$(PASSWORD) ${REPO}/${IMAGENAME}:$(VERSION)
podman tag ${REPO}/${IMAGENAME}:$(VERSION) ${REPO}/${IMAGENAME}:latest
@ echo "Pushing images"
@ podman push --creds $(USERNAME):$(PASSWORD) ${REPO}/${IMAGENAME}:$(VERSION)
@ podman push --creds $(USERNAME):$(PASSWORD) ${REPO}/${IMAGENAME}:latest

39
autobuild.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -aeou pipefail
BASE_IMAGE="registry.opensuse.org/opensuse/tumbleweed"
TARGET_REPO="git.rre.nu/jonas/"
PACKAGE_NAME="dnsmasq"
echo "Pulling latest tumbleweed"
podman pull "${BASE_IMAGE}:latest"
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'")"
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_VERSION"
echo "latest : $LATEST_VERSION"
if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then
echo "No new $PACKAGE_NAME version detected"
exit 0
fi
#Updateing Makefile with latest image tag
sed -i 's/VERSION='"$CURRENT_TUMBLEWEED_TAG"'/VERSION='"$LATEST_TUMBLEWEED_TAG"'/' Makefile
git add Makefile
git commit -m "Updated tumpleweed image to $LATEST_TUMBLEWEED_TAG, $PACKAGE_NAME to $LATEST_VERSION"
git push
echo "build and push new image"
make release