Files
MoShiro/ci/publish-dev-node-index.sh
T
justme 4515d7b075
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/dev-image Pipeline failed
scripts: publish unified Agent artifacts and restore CI coverage [CI]
Remove Probe build jobs and release paths. Transfer Gitea publishing credentials to both Agent architecture jobs, publish each platform archive once, and run slow tests after development images are published.
2026-10-21 11:56:06 +08:00

80 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Publish the pullable multi-architecture development tags for Agent.
set -euo pipefail
component="${1:?usage: publish-dev-node-index.sh <agent>}"
case "$component" in
agent) ;;
*) echo "unsupported component: $component" >&2; exit 2 ;;
esac
[[ "${CI_PIPELINE_EVENT:-}" == push && "${CI_COMMIT_BRANCH:-}" == main && "${CI_COMMIT_MESSAGE:-}" == *"[CI]"* ]] || {
echo "development node indexes require a main push with [CI] in the commit message" >&2
exit 2
}
[[ "${CI_COMMIT_SHA:-}" =~ ^[0-9a-fA-F]{40}$ ]] || {
echo "CI_COMMIT_SHA must be a full commit SHA" >&2
exit 2
}
[[ -n "${ZOT_USERNAME:-}" && -n "${ZOT_SECRET:-}" ]] || {
echo "Zot credentials are required" >&2
exit 2
}
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "$root/ci/version.sh"
registry="${ZOT_REGISTRY:-registry.oeo.one}"
repository="$registry/moshiro-dev/moshiro-$component"
work="$root/.release/dev-image-index/$component"
buildah_home="/home/justme/woodpecker/buildah-home/dev-node-index-$component"
export HOME="$buildah_home"
export REGISTRY_AUTH_FILE="$work/auth.json"
mkdir -p "$work" "$buildah_home"
source "$root/ci/buildah-env.sh"
moshiro_setup_buildah "$buildah_home"
logged_in=false
for attempt in 1 2 3 4; do
if buildah login --tls-verify=true --username "$ZOT_USERNAME" --password-stdin "$registry" <<< "$ZOT_SECRET" >/dev/null; then
logged_in=true
break
fi
if [[ "$attempt" -lt 4 ]]; then
echo "Zot login attempt $attempt failed; retrying in 3 seconds" >&2
sleep 3
fi
done
[[ "$logged_in" == true ]] || { echo "could not authenticate to Zot after 4 attempts" >&2; exit 1; }
manifest="localhost/moshiro-$component:$MOSHIRO_VERSION-multiarch"
buildah manifest rm "$manifest" >/dev/null 2>&1 || true
buildah manifest create "$manifest" >/dev/null
buildah manifest add "$manifest" "docker://$repository:$MOSHIRO_VERSION-amd64" >/dev/null
buildah manifest add "$manifest" "docker://$repository:$MOSHIRO_VERSION-arm64" >/dev/null
push_tag() {
local tag="$1" digest_file="$2"
buildah manifest push --all --format oci --digestfile "$digest_file" \
"$manifest" "docker://$repository:$tag" >/dev/null
echo "published multi-architecture development image $repository:$tag"
}
version_digest="$work/$component-$MOSHIRO_VERSION.digest"
latest_digest="$work/$component-latest.digest"
push_tag "$MOSHIRO_VERSION" "$version_digest" & version_pid=$!
push_tag latest "$latest_digest" & latest_pid=$!
push_status=0
wait "$version_pid" || push_status=1
wait "$latest_pid" || push_status=1
[[ "$push_status" == 0 ]] || { echo "one or more $component manifest pushes failed" >&2; exit 1; }
[[ "$(cat "$version_digest")" == "$(cat "$latest_digest")" ]] || {
echo "$component version and latest tags resolved to different manifest digests" >&2
exit 1
}
cp "$version_digest" "$work/$component.digest"
buildah manifest rm "$manifest" >/dev/null
if [[ -n "${RELEASE_SIGNING_KEY:-}" ]]; then
bash "$root/ci/publish-release-offer.sh" "$component" "$repository" \
"$(cat "$work/$component.digest")" "$MOSHIRO_TAG" dev "$work/release"
fi