diff --git a/.github/workflows/support/scripts/generate-docker-artifact-baseline.sh b/.github/workflows/support/scripts/generate-docker-artifact-baseline.sh index ea8d59d8..a7fe1a15 100755 --- a/.github/workflows/support/scripts/generate-docker-artifact-baseline.sh +++ b/.github/workflows/support/scripts/generate-docker-artifact-baseline.sh @@ -115,86 +115,86 @@ start_group "Configuring Environment" fi end_task "DONE (Found: ${DOCKER})" -# start_task "Resolving the Docker Client Configuration" -# SKOPEO_BIND_MOUNT="" -# SKOPEO_CREDENTIAL_OPTS="" -# DOCKER_CONFIG_DIR="${HOME}/.docker" -# if [[ -d "${DOCKER_CONFIG_DIR}" ]]; then -# SKOPEO_BIND_MOUNT="--volume ${DOCKER_CONFIG_DIR}:/tmp/docker" -# SKOPEO_CREDENTIAL_OPTS="--authfile /tmp/docker/config.json" -# fi -# export SKOPEO_BIND_MOUNT SKOPEO_CREDENTIAL_OPTS -# end_task "DONE" -# -# start_task "Checking for the SKOPEO command" -# if command -v skopeo >/dev/null 2>&1; then -# SKOPEO="$(command -v skopeo)" || fail "ERROR (Exit Code: ${?})" "${?}" -# export SKOPEO -# else -# ${DOCKER} pull "${SKOPEO_IMAGE_NAME}" >/dev/null 2>&1 || fail "ERROR (Exit Code: ${?})" "${?}" -# SKOPEO="${DOCKER} run ${SKOPEO_BIND_MOUNT} --rm --network host ${SKOPEO_IMAGE_NAME}" -# export SKOPEO -# fi -# end_task "DONE (Found: ${SKOPEO})" -# -# start_task "Checking for the JQ command" -# if command -v jq >/dev/null 2>&1; then -# JQ="$(command -v jq)" || fail "ERROR (Exit Code: ${?})" "${?}" -# export JQ -# else -# fail "ERROR (Exit Code: ${?})" "${?}" -# fi -# end_task "DONE (Found: ${JQ})" -#end_group -# -#start_group "Prepare the Docker Image Information" -# start_task "Resolving the DOCKER_REGISTRY variable" -# if [[ -z "${DOCKER_REGISTRY}" ]]; then -# DOCKER_REGISTRY="localhost:5000" -# fi -# end_task "DONE (Registry: ${DOCKER_REGISTRY})" -# -# start_task "Resolving the DOCKER_TAG variable" -# if [[ -z "${DOCKER_TAG}" ]]; then -# DOCKER_TAG="$(echo "${GITHUB_SHA}" | tr -d '[:space:]' | cut -c1-8)" -# fi -# end_task "DONE (Tag: ${DOCKER_TAG})" -# -# start_task "Resolving the Fully Qualified Image Name" -# FQ_IMAGE_NAME="${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${DOCKER_TAG}" -# end_task "DONE (Image: ${FQ_IMAGE_NAME})" -#end_group -# -#start_group "Generate Docker Image Manifest (linux/amd64)" -# ${SKOPEO} --override-os linux --override-arch amd64 inspect ${SKOPEO_CREDENTIAL_OPTS} --tls-verify=false "docker://${FQ_IMAGE_NAME}" | tee "${TEMP_DIR}/linux-amd64.manifest.json" || fail "SKOPEO ERROR (Exit Code: ${?})" "${?}" -# ${JQ} -r '.Layers[]' "${TEMP_DIR}/linux-amd64.manifest.json" | tee "${TEMP_DIR}/linux-amd64.layers.json" >/dev/null 2>&1 || fail "JQ LAYER ERROR (Exit Code: ${?})" "${?}" -# ${JQ} -r 'del(.RepoTags) | del(.LayersData) | del(.Digest) | del(.Name)' "${TEMP_DIR}/linux-amd64.manifest.json" | tee "${TEMP_DIR}/linux-amd64.comparable.json" >/dev/null 2>&1 || fail "JQ COMP ERROR (Exit Code: ${?})" "${?}" -#end_group -# -#start_group "Generate Docker Image Manifest (linux/arm64)" -# ${SKOPEO} --override-os linux --override-arch arm64 inspect ${SKOPEO_CREDENTIAL_OPTS} --tls-verify=false "docker://${FQ_IMAGE_NAME}" | tee "${TEMP_DIR}/linux-arm64.manifest.json" || fail "SKOPEO ERROR (Exit Code: ${?})" "${?}" -# ${JQ} -r '.Layers[]' "${TEMP_DIR}/linux-arm64.manifest.json" | tee "${TEMP_DIR}/linux-arm64.layers.json" >/dev/null 2>&1 || fail "JQ LAYER ERROR (Exit Code: ${?})" "${?}" -# ${JQ} -r 'del(.RepoTags) | del(.LayersData) | del(.Digest) | del(.Name)' "${TEMP_DIR}/linux-arm64.manifest.json" | tee "${TEMP_DIR}/linux-arm64.comparable.json" >/dev/null 2>&1 || fail "JQ COMP ERROR (Exit Code: ${?})" "${?}" -#end_group -# -#start_group "Generating Final Release Manifests" -# -# start_task "Generating the manifest archive" -# MANIFEST_FILES=("linux-amd64.manifest.json" "linux-amd64.layers.json" "linux-amd64.comparable.json") -# MANIFEST_FILES+=("linux-arm64.manifest.json" "linux-arm64.layers.json" "linux-arm64.comparable.json") -# tar -czf "${TEMP_DIR}/manifest.tar.gz" -C "${TEMP_DIR}" "${MANIFEST_FILES[@]}" >/dev/null 2>&1 || fail "TAR ERROR (Exit Code: ${?})" "${?}" -# end_task -# -# start_task "Copying the manifest files" -# cp "${TEMP_DIR}/manifest.tar.gz" "${MANIFEST_PATH}/${GITHUB_SHA}.tar.gz" || fail "COPY ERROR (Exit Code: ${?})" "${?}" -# cp "${TEMP_DIR}"/*.json "${MANIFEST_PATH}/" || fail "COPY ERROR (Exit Code: ${?})" "${?}" -# end_task "DONE (Path: ${MANIFEST_PATH}/${GITHUB_SHA}.tar.gz)" -# -# start_task "Setting Step Outputs" -# { -# printf "path=%s\n" "${MANIFEST_PATH}" -# printf "file=%s\n" "${MANIFEST_PATH}/${GITHUB_SHA}.tar.gz" -# printf "name=%s\n" "${GITHUB_SHA}.tar.gz" -# } >> "${GITHUB_OUTPUT}" -# end_task + start_task "Resolving the Docker Client Configuration" + SKOPEO_BIND_MOUNT="" + SKOPEO_CREDENTIAL_OPTS="" + DOCKER_CONFIG_DIR="${HOME}/.docker" + if [[ -d "${DOCKER_CONFIG_DIR}" ]]; then + SKOPEO_BIND_MOUNT="--volume ${DOCKER_CONFIG_DIR}:/tmp/docker" + SKOPEO_CREDENTIAL_OPTS="--authfile /tmp/docker/config.json" + fi + export SKOPEO_BIND_MOUNT SKOPEO_CREDENTIAL_OPTS + end_task "DONE" + + start_task "Checking for the SKOPEO command" + if command -v skopeo >/dev/null 2>&1; then + SKOPEO="$(command -v skopeo)" || fail "ERROR (Exit Code: ${?})" "${?}" + export SKOPEO + else + ${DOCKER} pull "${SKOPEO_IMAGE_NAME}" >/dev/null 2>&1 || fail "ERROR (Exit Code: ${?})" "${?}" + SKOPEO="${DOCKER} run ${SKOPEO_BIND_MOUNT} --rm --network host ${SKOPEO_IMAGE_NAME}" + export SKOPEO + fi + end_task "DONE (Found: ${SKOPEO})" + + start_task "Checking for the JQ command" + if command -v jq >/dev/null 2>&1; then + JQ="$(command -v jq)" || fail "ERROR (Exit Code: ${?})" "${?}" + export JQ + else + fail "ERROR (Exit Code: ${?})" "${?}" + fi + end_task "DONE (Found: ${JQ})" +end_group + +start_group "Prepare the Docker Image Information" + start_task "Resolving the DOCKER_REGISTRY variable" + if [[ -z "${DOCKER_REGISTRY}" ]]; then + DOCKER_REGISTRY="localhost:5000" + fi + end_task "DONE (Registry: ${DOCKER_REGISTRY})" + + start_task "Resolving the DOCKER_TAG variable" + if [[ -z "${DOCKER_TAG}" ]]; then + DOCKER_TAG="$(echo "${GITHUB_SHA}" | tr -d '[:space:]' | cut -c1-8)" + fi + end_task "DONE (Tag: ${DOCKER_TAG})" + + start_task "Resolving the Fully Qualified Image Name" + FQ_IMAGE_NAME="${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${DOCKER_TAG}" + end_task "DONE (Image: ${FQ_IMAGE_NAME})" +end_group + +start_group "Generate Docker Image Manifest (linux/amd64)" + ${SKOPEO} --override-os linux --override-arch amd64 inspect ${SKOPEO_CREDENTIAL_OPTS} --tls-verify=false "docker://${FQ_IMAGE_NAME}" | tee "${TEMP_DIR}/linux-amd64.manifest.json" || fail "SKOPEO ERROR (Exit Code: ${?})" "${?}" + ${JQ} -r '.Layers[]' "${TEMP_DIR}/linux-amd64.manifest.json" | tee "${TEMP_DIR}/linux-amd64.layers.json" >/dev/null 2>&1 || fail "JQ LAYER ERROR (Exit Code: ${?})" "${?}" + ${JQ} -r 'del(.RepoTags) | del(.LayersData) | del(.Digest) | del(.Name)' "${TEMP_DIR}/linux-amd64.manifest.json" | tee "${TEMP_DIR}/linux-amd64.comparable.json" >/dev/null 2>&1 || fail "JQ COMP ERROR (Exit Code: ${?})" "${?}" +end_group + +start_group "Generate Docker Image Manifest (linux/arm64)" + ${SKOPEO} --override-os linux --override-arch arm64 inspect ${SKOPEO_CREDENTIAL_OPTS} --tls-verify=false "docker://${FQ_IMAGE_NAME}" | tee "${TEMP_DIR}/linux-arm64.manifest.json" || fail "SKOPEO ERROR (Exit Code: ${?})" "${?}" + ${JQ} -r '.Layers[]' "${TEMP_DIR}/linux-arm64.manifest.json" | tee "${TEMP_DIR}/linux-arm64.layers.json" >/dev/null 2>&1 || fail "JQ LAYER ERROR (Exit Code: ${?})" "${?}" + ${JQ} -r 'del(.RepoTags) | del(.LayersData) | del(.Digest) | del(.Name)' "${TEMP_DIR}/linux-arm64.manifest.json" | tee "${TEMP_DIR}/linux-arm64.comparable.json" >/dev/null 2>&1 || fail "JQ COMP ERROR (Exit Code: ${?})" "${?}" +end_group + +start_group "Generating Final Release Manifests" + + start_task "Generating the manifest archive" + MANIFEST_FILES=("linux-amd64.manifest.json" "linux-amd64.layers.json" "linux-amd64.comparable.json") + MANIFEST_FILES+=("linux-arm64.manifest.json" "linux-arm64.layers.json" "linux-arm64.comparable.json") + tar -czf "${TEMP_DIR}/manifest.tar.gz" -C "${TEMP_DIR}" "${MANIFEST_FILES[@]}" >/dev/null 2>&1 || fail "TAR ERROR (Exit Code: ${?})" "${?}" + end_task + + start_task "Copying the manifest files" + cp "${TEMP_DIR}/manifest.tar.gz" "${MANIFEST_PATH}/${GITHUB_SHA}.tar.gz" || fail "COPY ERROR (Exit Code: ${?})" "${?}" + cp "${TEMP_DIR}"/*.json "${MANIFEST_PATH}/" || fail "COPY ERROR (Exit Code: ${?})" "${?}" + end_task "DONE (Path: ${MANIFEST_PATH}/${GITHUB_SHA}.tar.gz)" + + start_task "Setting Step Outputs" + { + printf "path=%s\n" "${MANIFEST_PATH}" + printf "file=%s\n" "${MANIFEST_PATH}/${GITHUB_SHA}.tar.gz" + printf "name=%s\n" "${GITHUB_SHA}.tar.gz" + } >> "${GITHUB_OUTPUT}" + end_task end_group