Files
forgerunner/scripts/publish-image.sh
T
Jason Stedwell 1ad33c2396
CI Smoke / toolchain (push) Successful in 1s
Make v0.1.0 Unraid-ready: multi-arch image, correct image path, registry-login docs
- Publish v0.1.0/latest as multi-arch (linux/amd64+arm64); amd64 passes 17/17 smoke
- publish-image.sh: add PLATFORMS multi-arch buildx mode (reproducible amd64 build)
- compose + unraid notes: fix image path to include jason/ namespace
- unraid notes: document required docker login (private package) and host label
  for docker build/push jobs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 22:18:38 -05:00

62 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# publish-image.sh — tag and push the runner image to a registry
set -euo pipefail
IMAGE_NAME="${IMAGE_NAME:-custom-gitea-runner}"
REGISTRY="${REGISTRY:-registry.alwisp.com}"
# Gitea Container Registry namespaces images under an owner (user/org), e.g.
# registry.alwisp.com/<owner>/<image>. Set REGISTRY_NAMESPACE to that owner.
REGISTRY_NAMESPACE="${REGISTRY_NAMESPACE:-jason}"
VERSION="${VERSION:-}"
if [ -z "$VERSION" ]; then
echo "[ERROR] VERSION must be set (e.g. VERSION=v0.1.0 ./scripts/publish-image.sh)"
exit 1
fi
# Build the remote repository path, including the namespace when one is set.
if [ -n "${REGISTRY_NAMESPACE}" ]; then
REMOTE_REPO="${REGISTRY}/${REGISTRY_NAMESPACE}/${IMAGE_NAME}"
else
REMOTE_REPO="${REGISTRY}/${IMAGE_NAME}"
fi
LOCAL_TAG="${IMAGE_NAME}:${VERSION}"
REMOTE_TAG="${REMOTE_REPO}:${VERSION}"
REMOTE_LATEST="${REMOTE_REPO}:latest"
# PLATFORMS (e.g. "linux/amd64,linux/arm64") triggers a multi-arch buildx build
# that is pushed directly as a single manifest list. This is the recommended
# path: Unraid hosts are amd64, so the published image must include amd64 even
# when built on an arm64 (Apple Silicon) machine. Leave unset for a single-arch
# tag-and-push of an already-built local image.
PLATFORMS="${PLATFORMS:-}"
if [ -n "${PLATFORMS}" ]; then
VCS_REF="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)"
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "Building and pushing multi-arch (${PLATFORMS}) ${REMOTE_TAG} ..."
docker buildx build \
--platform "${PLATFORMS}" \
--build-arg "VERSION=${VERSION}" \
--build-arg "VCS_REF=${VCS_REF}" \
--build-arg "BUILD_DATE=${BUILD_DATE}" \
--tag "${REMOTE_TAG}" \
--tag "${REMOTE_LATEST}" \
--file docker/runner/Dockerfile \
--push \
.
echo "Published multi-arch: ${REMOTE_TAG} (${PLATFORMS})"
exit 0
fi
echo "Tagging ${LOCAL_TAG} as ${REMOTE_TAG} ..."
docker tag "${LOCAL_TAG}" "${REMOTE_TAG}"
docker tag "${LOCAL_TAG}" "${REMOTE_LATEST}"
echo "Pushing ${REMOTE_TAG} ..."
docker push "${REMOTE_TAG}"
docker push "${REMOTE_LATEST}"
echo "Published: ${REMOTE_TAG}"