restic/Makefile

54 lines
1.8 KiB
Makefile
Raw Normal View History

2023-04-17 11:33:20 +00:00
.PHONY: default build clean release require_clean_git
2023-04-12 14:47:01 +00:00
-include .env
2023-04-18 11:59:35 +00:00
VERSION=20230416
2023-04-17 11:33:20 +00:00
IMAGENAME=restic
2023-04-17 17:43:44 +00:00
REPO=git.rre.nu/jonas
2023-04-18 11:53:24 +00:00
TITLE=restic with openSSH based on openSUSE Tumpleweed
DESC=Image containing restic & openSSH, based on openSUSE Tumbleweed
2023-04-12 14:47:01 +00:00
2023-04-18 11:29:16 +00:00
BUILD_TIME := $(shell TZ=UTC date --iso-8601=ns)
2023-04-12 14:47:01 +00:00
SHELL := /bin/bash
2023-04-18 11:53:24 +00:00
default: build
2023-04-17 11:33:20 +00:00
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
2023-04-12 15:02:55 +00:00
2023-04-12 14:47:01 +00:00
build:
2023-04-18 11:29:16 +00:00
podman build \
2023-04-18 11:53:24 +00:00
--build-arg VERSION="$(VERSION)" \
2023-04-18 12:09:01 +00:00
--label org.opencontainers.image.source="https://${REPO}/${IMAGENAME}/src/tag/v${VERSION}" \
2023-04-18 11:53:24 +00:00
--label org.opencontainers.image.title="${TITLE}" \
--label org.opencontainers.image.description="${DESC}" \
--label org.opencontainers.image.created="$(shell TZ=UTC date --iso-8601=ns)" \
2023-04-18 12:12:46 +00:00
--label org.opencontainers.image.url="https://${REPO}/-/packages/container/${IMAGENAME}/${VERSION}" \
2023-04-18 11:53:24 +00:00
--label org.opencontainers.image.version="${VERSION}" \
--label org.opencontainers.image.vendor="Jonas Forsberg" \
--tag ${REPO}/${IMAGENAME}:$(VERSION) \
2023-04-18 11:29:16 +00:00
.
2023-04-12 14:47:01 +00:00
2023-04-12 15:02:55 +00:00
clean:
2023-04-18 11:56:01 +00:00
podman image rm ${REPO}/${IMAGENAME}:$(VERSION)
2023-04-12 15:02:55 +00:00
2023-04-17 11:33:20 +00:00
release: require_clean_git build
2023-04-17 12:21:03 +00:00
$(eval TMP_MESSAGE := $(shell podman run --rm -it ${REPO}/${IMAGENAME}:$(VERSION) /usr/bin/restic --version))
git tag -a v$(VERSION) -m "restic version: ${TMP_MESSAGE}"
2023-04-17 11:33:20 +00:00
git push origin v$(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