2025-04-06 19:35:03 +01:00
#!/bin/env sh
set -e
# Change to the directory where the script is located
cd " $( dirname " $0 " ) "
DATE_TAG = $( date "+%Y%m%d-%H%M%S" )
2025-05-17 19:25:52 +01:00
CURRENT_IMAGE_ID = $( podman images --format "{{.ID}}" cremin.dev/jonathan/ublue-silverblue-nvidia:42)
2025-04-06 19:35:03 +01:00
echo "Pulling base image"
# ensure the base image is up to date
2025-05-17 19:25:52 +01:00
podman pull ghcr.io/ublue-os/silverblue-nvidia:42
2025-04-06 19:35:03 +01:00
echo "Starting build"
2025-05-17 19:25:52 +01:00
podman build -t cremin.dev/jonathan/ublue-silverblue-nvidia:42 .
2025-04-06 19:35:03 +01:00
2025-05-17 19:25:52 +01:00
NEW_IMAGE_ID = $( podman images --format "{{.ID}}" cremin.dev/jonathan/ublue-silverblue-nvidia:42)
2025-04-06 19:35:03 +01:00
# Start build and check if any layers were changed (looking for "Using cache" messages)
if [ " $CURRENT_IMAGE_ID " = " $NEW_IMAGE_ID " ] ; then
echo "No changes detected, skipping push"
else
echo "Image updated, pushing to registry"
# Add the tags
2025-05-17 19:25:52 +01:00
podman tag cremin.dev/jonathan/ublue-silverblue-nvidia:42 cremin.dev/jonathan/ublue-silverblue-nvidia:42-${ DATE_TAG } cremin.dev/jonathan/ublue-silverblue-nvidia:latest
2025-04-06 19:35:03 +01:00
# Push the image
2025-05-17 19:25:52 +01:00
podman push --authfile ~/.config/containers/auth.json cremin.dev/jonathan/ublue-silverblue-nvidia:42-${ DATE_TAG }
podman push --authfile ~/.config/containers/auth.json cremin.dev/jonathan/ublue-silverblue-nvidia:42
podman push --authfile ~/.config/containers/auth.json cremin.dev/jonathan/ublue-silverblue-nvidia:latest
2025-04-06 19:35:03 +01:00
fi