Skip to content

Commit

Permalink
Merge pull request #13 from Conjur-Enterprise/automated-releases
Browse files Browse the repository at this point in the history
CNJR-6740: Fix image publishing
  • Loading branch information
gl-johnson authored and GitHub Enterprise committed Nov 7, 2024
2 parents 221536f + 5794601 commit 16e3be6
Showing 1 changed file with 8 additions and 37 deletions.
45 changes: 8 additions & 37 deletions scripts/publish_container_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ cd "$(dirname "${0}")"

function print_help() {
echo "Internal Release Usage: ${0} --internal"
echo "External Release Usage: ${0} --edge"
echo "External Release Usage: ${0}"
echo "Promote Usage: ${0} --promote --source <VERSION> --target <VERSION>"
echo " --internal: publish images to registry.tld"
echo " --edge: publish docker images to docker hub"
echo " --source <VERSION>: specify version number of local image"
echo " --target <VERSION>: specify version number of remote image"
}
Expand All @@ -25,7 +24,6 @@ if [[ $# -lt 1 ]]; then
fi

PUBLISH_INTERNAL=false
PUBLISH_EDGE=false
PROMOTE=false
PULL_SOURCE_IMAGES=false

Expand All @@ -37,9 +35,6 @@ while [[ $# -gt 0 ]]; do
--pull)
PULL_SOURCE_IMAGES=true
;;
--edge)
PUBLISH_EDGE=true
;;
--promote)
PROMOTE=true
;;
Expand All @@ -64,40 +59,20 @@ while [[ $# -gt 0 ]]; do
shift
done

readonly REGISTRY="conjurinc"
readonly LOCAL_REGISTRY="registry.tld"
readonly INTERNAL_REGISTRY="registry.tld"
# Version derived from CHANGLEOG and automated release library
VERSION_WITH_COMMIT="$(project_version_with_commit)"
readonly VERSION_WITH_COMMIT
readonly IMAGES=(
"conjur-service-broker"
)
readonly IMAGE_NAME="conjur-service-broker"


if [[ ${PUBLISH_INTERNAL} = true ]]; then
echo "Publishing built images internally to registry.tld."
SOURCE_TAG=${VERSION_WITH_COMMIT}
REMOTE_TAG=${VERSION_WITH_COMMIT}

echo "SOURCE_TAG=${SOURCE_TAG}, REMOTE_TAG=${REMOTE_TAG}"
for IMAGE_NAME in "${IMAGES[@]}"; do
tag_and_push "${IMAGE_NAME}:${SOURCE_TAG}" "${LOCAL_REGISTRY}/${IMAGE_NAME}:${REMOTE_TAG}"
done
fi

if [[ ${PUBLISH_EDGE} = true ]]; then
echo "Performing edge release."
SOURCE_TAG=${VERSION_WITH_COMMIT}

if [[ ${PULL_SOURCE_IMAGES} = true ]]; then
echo "Pulling source images from local registry"
for IMAGE_NAME in "${IMAGES[@]}"; do
docker pull "${LOCAL_REGISTRY}/${IMAGE_NAME}:${SOURCE_TAG}"
done
fi

for IMAGE_NAME in "${IMAGES[@]}"; do
tag_and_push "${IMAGE_NAME}:${SOURCE_TAG}" "${REGISTRY}/${IMAGE_NAME}:edge"
done
tag_and_push "${IMAGE_NAME}:${SOURCE_TAG}" "${INTERNAL_REGISTRY}/${IMAGE_NAME}:${REMOTE_TAG}"
fi

if [[ ${PROMOTE} = true ]]; then
Expand All @@ -119,14 +94,10 @@ if [[ ${PROMOTE} = true ]]; then

if [[ ${PULL_SOURCE_IMAGES} = true ]]; then
echo "Pulling source images from local registry"
for IMAGE_NAME in "${IMAGES[@]}"; do
docker pull "${LOCAL_REGISTRY}/${IMAGE_NAME}:${SOURCE_TAG}"
done
docker pull "${INTERNAL_REGISTRY}/${IMAGE_NAME}:${SOURCE_TAG}"
fi

for IMAGE_NAME in "${IMAGES[@]}"; do
for tag in "${TAGS[@]}" $(gen_versions "${REMOTE_TAG}"); do
tag_and_push "${LOCAL_REGISTRY}/${IMAGE_NAME}:${SOURCE_TAG}" "${REGISTRY}/${IMAGE_NAME}:${tag}"
done
for tag in "${TAGS[@]}" $(gen_versions "${REMOTE_TAG}"); do
tag_and_push "${INTERNAL_REGISTRY}/${IMAGE_NAME}:${SOURCE_TAG}" "${INTERNAL_REGISTRY}/${IMAGE_NAME}:${tag}"
done
fi

0 comments on commit 16e3be6

Please sign in to comment.