Compare commits

...

8 Commits

Author SHA1 Message Date
Jonas Forsberg
bcc246d345 added first autobuild 2023-04-17 09:59:57 +02:00
Jonas Forsberg
5d4eb1922d forgot \ 2023-04-13 17:09:44 +02:00
Jonas Forsberg
e59099570c forgot ; 2023-04-13 17:08:54 +02:00
Jonas Forsberg
49116b883b I cross my fingers... 2023-04-13 17:08:14 +02:00
Jonas Forsberg
98e5ebf825 yet another try 2023-04-13 17:06:25 +02:00
Jonas Forsberg
e75ec99fcd another try on clean git 2023-04-13 17:03:08 +02:00
Jonas Forsberg
5be3153522 yet another guard try 2023-04-13 16:46:12 +02:00
Jonas Forsberg
3e8c266ae0 fixed guard 2023-04-13 16:41:58 +02:00
2 changed files with 48 additions and 4 deletions

View File

@ -1,4 +1,4 @@
.PHONY: default build clean release
.PHONY: default build clean release require_clean_git
-include .env
@ -10,8 +10,18 @@ SHELL := /bin/bash
default: build
guard:
@ if [ -z "$(git status --porcelain)" ]; then echo "git repo not clean"; exit 1; fi
require_clean_git:
git update-index -q --ignore-submodules --refresh
git diff-files --quiet --ignore-submodules
git diff-index --cached --quiet --ignore-submodules HEAD --
@status=$$(git status --porcelain); \
if test "x$${status}" = x; then \
echo "No untracked files detected"; \
else \
echo "Untracked files detected" >&2; \
exit 1; \
fi
build:
podman build --build-arg VERSION=$(VERSION) --tag ${REPO}/${IMAGENAME}:$(VERSION) .
@ -19,7 +29,7 @@ build:
clean:
podman image rm ${REPO}/${IMAGENAME}:$(VERSION)
release: guard build
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 push origin v$(VERSION)

34
autobuild.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -aeou pipefail
BASE_IMAGE="registry.opensuse.org/opensuse/tumbleweed"
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_DNSMASQ_VERSION="$(podman run --rm -it ${BASE_IMAGE}:${CURRENT_TUMBLEWEED_TAG} zypper ref > /dev/null && zypper info dnsmasq | 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')"
echo "current : $CURRENT_DNSMASQ_VERSION"
echo "latest : $LATEST_DNSMASQ_VERSION"
if [[ "$CURRENT_DNSMASQ_VERSION" == "$LATEST_DNSMASQ_VERSION" ]]; then
echo "No new dnsmasq 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 "
git push
echo "build and push new image"
make release